+pl 1.1.3-1
+ - great renaming of String and String_convert interfaces
+ - more conversions moved (copied actually) to String_convert
+ - String indexing now all base = 0, not found = -1
+ - renamed by to byte
+
+pl 1.1.3
+ - String::mid
+ - memmove test code
pl 1.1.2
- StringConversio::bin2int_i
cc=choleski.cc datafile.cc dstream.cc lgetopt.cc matdebug.cc matrix.cc\
-path.cc scalar.cc smat.cc string.cc stringconversion.cc stringutil.cc\
+path.cc scalar.cc smat.cc string.cc string-convert.cc stringutil.cc\
textdb.cc textstream.cc unionfind.cc vector.cc
templatecc=cursor.tcc list.tcc plist.tcc interval.tcc\
hh=assoc.hh associter.hh choleski.hh compare.hh cursor.hh dstream.hh\
fproto.hh handle.hh interval.hh iterate.hh lgetopt.hh link.hh list.hh\
matrix.hh path.hh pcursor.hh plist.hh rational.hh real.hh scalar.hh\
-smat.hh string.hh stringconversion.hh stringhandle.hh stringdata.hh\
+smat.hh string.hh string-convert.hh stringhandle.hh stringdata.hh\
textdb.hh textstream.hh unionfind.hh pqueue.hh\
varray.hh vector.hh vsmat.hh datafile.hh
static String
strip_pretty(String pret)
{
- String cl(pret.left(pret.pos('(')-1));
- int l = cl.lastPos(' ');
- cl = cl.right(cl.len() -l);
+ String cl(pret.left_str(pret.index_i('(')));
+ int l = cl.index_last_i(' ');
+ cl = cl.right_str(cl.len() - l - 1);
return cl;
}
static String
strip_member(String pret)
{
- String cl(pret.left(pret.lastPos(':')-2));
+ String cl(pret.left_str(pret.index_last_i(':')-1));
return cl;
}
struct Matrix ;
struct String_data ;
struct String_handle ;
+struct String_convert;
struct String;
struct virtual_smat ;
struct Vector ;
String &drive, String &dirs, String &filebase, String &extension)
{
// peel off components, one by one.
- int di = path.pos(':');
- if (di)
+ int di = path.index_i(':');
+ if (di >= 0)
{
- drive = path.left(di);
- path = path.right(path.len() - di);
+ drive = path.left_str(di + 1);
+ path = path.right_str(path.len() - di -1);
}
else
drive = "";
- di = path.lastPos(PATHSEP);
- if (di)
+ di = path.index_last_i(PATHSEP);
+ if (di >=0)
{
- dirs = path.left(di);
- path = path.right(path.len()-di);
+ dirs = path.left_str(di + 1);
+ path = path.right_str(path.len()-di -1);
}
else
dirs = "";
- di = path.lastPos('.');
- if (di)
+ di = path.index_last_i('.');
+ if (di >= 0)
{
- di --; // don't forget '.'
- filebase = path.left(di);
- extension =path.right(path.len()-di);
+ filebase = path.left_str(di);
+ extension =path.right_str(path.len()-di);
}
else
{
Scalar::operator Rational()
{
- int p = pos('/');
- if (!p)
+ int p = index_i('/');
+ if (p == -1)
return int(*this);
- String s2 = right(len()-p);
- p--;
- String s1 = left(p);
+ String s2 = right_str(len()-p-1);
+ String s1 = left_str(p);
- return Rational(s1.value(), s2.value());
+ return Rational(s1.value_i(), s2.value_i());
}
bool
Scalar::operator Real()
{
assert (isnum());
- return fvalue();
+ return value_f();
}
Scalar::operator int()
{
assert (isnum());
- return value();
+ return value_i();
}
if (*this == "0")
return false;
String u (*this);
- u.upper();
- if (u== "FALSE")
+ if ( u.upper_str() == "FALSE")
return false;
return true;
}
--- /dev/null
+/*
+ PROJECT: FlowerSoft C++ library
+ FILE : string-convert.cc
+
+--*/
+
+
+#include <assert.h>
+#include "string.hh"
+
+String
+String_convert::bin2hex_str( String bin_str )
+{
+ String str;
+ Byte const* byte_c_l = bin_str.byte_c_l();
+ for ( int i = 0; i < bin_str.length_i(); i++ ) {
+ str += (char)nibble2hex_byte( *byte_c_l >> 4 );
+ str += (char)nibble2hex_byte( *byte_c_l++ );
+ }
+ return str;
+}
+
+int
+String_convert::bin2_i( String bin_str )
+{
+ assert( bin_str.length_i() <= 4 );
+
+ int result_i = 0;
+ for ( int i = 0; i < bin_str.length_i(); i++ ) {
+ result_i <<= 8;
+ result_i += (Byte)bin_str[ i ];
+ }
+ return result_i;
+}
+
+// breendet imp from String
+int
+String_convert::dec2_i( String dec_str )
+{
+ if ( !dec_str.length_i() )
+ return 0;
+
+ long l = 0;
+ int conv = sscanf( dec_str.ch_c_l(), "%ld", &l );
+ assert( conv );
+
+ return (int)l;
+}
+
+// breendet imp from String
+double
+String_convert::dec2_f( String dec_str )
+{
+ if ( !dec_str.length_i() )
+ return 0;
+ double d = 0;
+ int conv = sscanf( dec_str.ch_c_l(), "%lf", &d );
+ assert( conv );
+ return d;
+}
+
+int
+String_convert::hex2bin_i( String hex_str, String& bin_str_r )
+{
+ if ( hex_str.length_i() % 2 )
+ hex_str = "0" + hex_str;
+
+ bin_str_r = "";
+ Byte const* byte_c_l= hex_str.byte_c_l();
+ int i = 0;
+ while ( i < hex_str.length_i() ) {
+ int high_i = hex2nibble_i( *byte_c_l++ );
+ int low_i = hex2nibble_i( *byte_c_l++ );
+ if ( high_i < 0 || low_i < 0 )
+ return 1; // illegal char
+ bin_str_r += String( (char)( high_i << 4 | low_i ), 1 );
+ i += 2;
+ }
+ return 0;
+}
+
+String
+String_convert::hex2bin_str( String hex_str )
+{
+ String str;
+// silly, asserts should alway be "on"!
+// assert( !hex2bin_i( hex_str, str ) );
+ int error_i = hex2bin_i( hex_str, str );
+ assert( !error_i );
+ return str;
+}
+
+int
+String_convert::hex2nibble_i( Byte byte )
+{
+ if ( byte >= '0' && byte <= '9' )
+ return byte - '0';
+ if ( byte >= 'A' && byte <= 'F' )
+ return byte - 'A' + 10;
+ if ( byte >= 'a' && byte <= 'f')
+ return byte - 'a' + 10;
+ return -1;
+}
+
+String
+String_convert::i2dec_str( int i, int length_i, char ch )
+{
+ char fill_ch = ch;
+ if ( fill_ch)
+ fill_ch = '0';
+
+ // ugh
+ String dec_str( i );
+
+ // ugh
+ return String( fill_ch, length_i - dec_str.length_i() ) + dec_str;
+}
+
+String
+String_convert::i2hex_str( int i, int length_i, char ch )
+{
+ String str;
+ if ( !i )
+ str = "0";
+ while ( i ) {
+ str = ( i % 16 )["0123456789abcdef"] + str;
+ i /= 16;
+ }
+ if ( str.length_i() < length_i )
+ str = String( ch, length_i - str.length_i() ) + str;
+ return str;
+}
+
+Byte
+String_convert::nibble2hex_byte( Byte byte )
+{
+ if ( ( byte & 0x0f ) <= 9 )
+ return ( byte & 0x0f ) + '0';
+ else
+ return ( byte & 0x0f ) - 10 + 'a';
+}
--- /dev/null
+/*
+ PROJECT: FlowerSoft C++ library
+ FILE : string-convert.hh
+
+*/
+
+#ifndef STRING_CONVERT_HH
+#define STRING_CONVERT_HH
+
+///
+#define functor class // :-)
+/**
+ The functor String_convert handles all conversions to/from String (some
+ time, anyway).
+ The class is quite empty from data view.
+ */
+functor String_convert {
+ static int hex2bin_i( String hex_str, String& bin_str_r );
+ static int hex2nibble_i( Byte byte );
+ static Byte nibble2hex_byte( Byte byte );
+public:
+ static String bin2dec_str( String dec_str );
+ static String bin2hex_str( String bin_str );
+ static String dec2bin_str( String str );
+ static int bin2_i( String str );
+ static int dec2_i( String dec_str );
+ static double dec2_f( String dec_str );
+ static int hex2int_i( String str );
+ static String hex2bin_str( String str );
+ static String i2hex_str( int i, int length_i, char ch );
+ static String i2dec_str( int i, int length_i, char ch );
+};
+
+#endif // __STRING_CONVERT_HH //
#include "string.hh"
#ifdef STRING_DEBUG
-void* mymemmove( void* dest, void* src, size_t n );
+void* mymemmove( void* dest, void const* src, size_t n );
#define memmove mymemmove
#endif
{
char* p = s;
- while( *p )
- {
+ while( *p ) {
*p = tolower( *p ); /* a macro on some compilers */
p++;
- }
+ }
return s;
}
{
char* p = s;
- while( *p )
- {
+ while( *p ) {
*p = toupper( *p ); /* a macro on some compilers */
p++;
- }
+ }
return s;
}
}
void
-String::printOn(ostream& os) const
+String::print_on(ostream& os) const
{
if ( length_i() == strlen( ch_c_l() ) )
os << ch_c_l();
String::String( const int i, const int n, char const c )
{
- char fillChar = c;
- if ( fillChar)
- fillChar = '0';
+ char fill_ch = c;
+ if ( fill_ch)
+ fill_ch = '0';
String v( i );
- String str = String( fillChar, n - v.length_i() ) + String( v );
+ String str = String( fill_ch, n - v.length_i() ) + String( v );
strh_.set( str.byte_c_l(), str.length_i() );
}
// signed comparison, analogous to memcmp;
int
-String::compare(String const& s1, String const& s2 )
+String::compare_i(String const& s1, String const& s2 )
{
Byte const* p1 = s1.byte_c_l();
Byte const* p2 = s2.byte_c_l();
int
-String::lastPos( char const c ) const
+String::index_last_i( char const c ) const
{
- // not binary safe
- assert( length_i() == strlen( ch_c_l() ) );
- char const* me = strh_.ch_c_l();
- int pos = 0;
- if ( length_i() )
- {
+ // not binary safe
+ assert( length_i() == strlen( ch_c_l() ) );
+ if ( !length_i() )
+ return -1;
+
+ char const* me = strh_.ch_c_l();
char const* p = strrchr(me, c );
- if ( p )
- pos = p - me + 1;
- }
- return pos;
+ if ( p )
+ return p - me;
+ return -1;
}
int
-String::lastPos( char const* string ) const
+String::index_last_i( char const* string ) const
{
- // not binary safe
- assert( length_i() == strlen( ch_c_l() ) );
- int pos = 0;
- int length = strlen( string );
- if ( length_i() && length )
- {
- int nextpos = this->pos( string );
- while( nextpos )
- {
- pos += nextpos;
- nextpos = right( length_i() - pos - length + 1 ).pos( string );
- }
- }
- return pos;
+ // not binary safe
+ assert( length_i() == strlen( ch_c_l() ) );
+
+ int length = strlen( string );
+ if ( !length_i() || !length )
+ return -1;
+
+ int next_i = index_i( string );
+ if ( next_i == -1 )
+ return -1;
+
+ int index_i = 0;
+ while( next_i >= 0 ) {
+ index_i += next_i;
+ next_i = right_str( length_i() - index_i - length ).index_i( string );
+ }
+ return index_i;
}
// find c
-// return 0 if not found.
+// return -1 if not found.
-// ? should return length_i()?, as in string.left(pos(delimiter))
+// ? should return length_i()?, as in string.left_str(index_i(delimiter))
int
-String::pos(char c ) const
+String::index_i(char c ) const
{
- // not binary safe
- assert( length_i() == strlen( ch_c_l() ) );
- char const* me = strh_.ch_c_l();
- int pos = 0;
- if ( length_i() )
- {
+ // not binary safe
+ assert( length_i() == strlen( ch_c_l() ) );
+ if ( !length_i() )
+ return -1;
+
+ char const* me = strh_.ch_c_l();
char const* p = strchr( me, c );
- if ( p )
- pos = p - me + 1;
- }
- return pos;
+ if ( p )
+ return p - me;
+ return -1;
}
// find searchfor. (what if this == "" && searchfor == "") ???
int
-String::pos( char const* searchfor ) const
-{
- // not binary safe
- assert( length_i() == strlen( ch_c_l() ) );
- char const* me = strh_.ch_c_l();
- int pos = 0;
- if ( length_i() && searchfor)
- {
+String::index_i( char const* searchfor ) const
+{
+ // not binary safe
+ assert( length_i() == strlen( ch_c_l() ) );
+ if ( !length_i() || !searchfor )
+ return -1;
+
+ char const* me = strh_.ch_c_l();
char const* p = strstr(me, searchfor);
- if ( p )
- pos = p - me + 1;
- }
- return pos;
+ if ( p )
+ return p - me;
+ return -1;
}
// find chars of a set.
int
-String::posAny( char const* string ) const
+String::index_any_i( char const* string ) const
{
- // not binary safe
- assert( length_i() == strlen( ch_c_l() ) );
- int pos = 0;
- char const* s = (char const* )strh_.ch_c_l();
- if ( length_i() && string )
- {
+ // not binary safe
+ assert( length_i() == strlen( ch_c_l() ) );
+
+ if ( !length_i() || !string )
+ return -1;
+
+ char const* s = (char const* )strh_.ch_c_l();
char const* p = strpbrk( s, string );
- if ( p )
- pos = p - s + 1;
- }
- return pos;
+ if ( p )
+ return p - s;
+ return -1;
}
String
-String::left( int n ) const
+String::left_str( int n ) const
{
if (n >= length_i())
return *this;
// n rightmst chars
String
-String::right( int n ) const
+String::right_str( int n ) const
{
if (n > length_i())
return *this;
String
-String::nomid( const int pos, const int n ) const
+String::nomid_str( int index_i, int n ) const
{
- String retval;
-
- if ( pos < 1 )
- return String("");
- if ( pos > length_i())
- return *this;
+ if ( index_i < 0 )
+ return String();
+ if ( index_i >= length_i() )
+ return *this;
- return String( String( left( pos - 1 ) ) + right( length_i() - pos - n + 1 ));
+ return String( String( left_str( index_i ) ) + right_str( length_i() - index_i - n ));
}
String
-String::mid( int pos, int n ) const
+String::mid_str( int index_i, int n ) const
{
- // HWN. This SUX: JCN: yep, please change me + all my invocations
- // pos 1 == strh_->string[ 0 ];
- // pos 0 allowed for convenience
- if ( !length_i() || ( pos < 0 ) || ( pos > length_i() ) && ( n < 1 ) )
- return String();
+ if ( !length_i() || ( index_i < 0 ) || ( index_i >= length_i() ) || ( n < 1 ) )
+ return String();
- // overflow...
- if ( ( n > length_i() ) || ( pos + n - 1 > length_i() ) )
- n = length_i() - pos + 1;
+ if ( ( n > length_i() ) || ( index_i + n > length_i() ) )
+ n = length_i() - index_i;
- return String( byte_c_l() + pos -1, n );
+ return String( byte_c_l() + index_i, n );
}
-// to uppercase
+// return uppercase
String
-String::upper()
+String::upper_str() const
{
// not binary safe
assert( length_i() == strlen( ch_c_l() ) );
- char *s = strh_.byte_l();
+ String str = *this;
+ char *s = str.strh_.byte_l();
strupr( s );
- return *this;
+ return str;
}
-// to lowercase
+// return lowercase
String
-String::lower()
+String::lower_str() const
{
// not binary safe
assert( length_i() == strlen( ch_c_l() ) );
- char* s = strh_.byte_l();
+ String str = *this;
+ char* s = str.strh_.ch_l();
strlwr(s);
- return *this;
+ return str;
}
String::String (double f, char const* fmt)
*this = buf;
}
-long
-String::value() const
+int
+String::value_i() const
{
- long l =0;
- if (length_i()) {
- int conv = sscanf(strh_.ch_c_l(), "%ld", &l);
- assert(conv);
- }
- return l;
+ return String_convert::dec2_i( *this );
}
double
-String::fvalue() const
+String::value_f() const
{
- double d =0;
- if (length_i()) {
- int conv = sscanf(strh_.ch_c_l(), "%lf", &d);
- assert(conv);
- }
- return d;
+ return String_convert::dec2_f( *this );
}
-String quoteString( String msg, String quote)
+#if 0
+String
+quoteString( String msg, String quote)
{
- return msg + " `" + quote + "' ";
+ return msg + " `" + quote + "' ";
}
-
+#endif // 0
Byte*
strrev( Byte* byte_l, int length_i )
{
- Byte by;
+ Byte byte;
Byte* left_byte_l = byte_l;
Byte* right_byte_l = byte_l + length_i;
while ( right_byte_l > left_byte_l ) {
- by = *left_byte_l;
+ byte = *left_byte_l;
*left_byte_l++ = *right_byte_l;
- *right_byte_l-- = by;
+ *right_byte_l-- = byte;
}
return byte_l;
}
String
-String::reversed() const
+String::reversed_str() const
{
String str = *this;
strrev( str.byte_l(), str.length_i() );
ref counting through #String_handle#
\item
- conversion from bool, int, double, char *, char.
+ conversion from bool, int, double, char* , char.
\item
- conversion to int, upcase, downcase
+ to be moved to String_convert:
+ conversion to int, upcase, downcase
\item
printable.
\item
- indexing (pos, posAny, lastPos)
+ indexing (index_i, index_any_i, last_index_i)
\item
- cutting (left, right, mid)
+ cutting (left_str, right_str, mid_str)
\item
concat (+=, +)
\item
No operator[] is provided, since this would be enormously slow. If needed,
- convert to const char *.
+ convert to char const* .
\end{itemize}
*/
class String
String() { }
String(Rational);
/// String s = "abc";
- String( const char* source );
+ String( char const* source );
- String( Byte const* l_byte_c, int length_i );
+ String( Byte const* byte_c_l, int length_i );
/// "ccccc"
String( char c, int n = 1 );
String(bool );
/// String s( 3.14, 6, '#' );
- String ( double f , const char *fmt =0);
+ String ( double f , char const* fmt =0);
String( int i, int n, char c = ' ' );
/// return a "new"-ed copy of contents
Byte* byte_l();
/// deprecated; use ch_c_l()
- operator const char *() const { return ch_c_l(); }
+ operator char const* () const { return ch_c_l(); }
String operator =( const String & source ) { strh_ = source.strh_; return *this; }
char operator []( int n ) const { return strh_[n]; }
/// return n leftmost chars
- String left( int n ) const;
+ String left_str( int n ) const;
/// return n rightmost chars
- String right( int n ) const;
+ String right_str( int n ) const;
- /// convert this to upcase
- String upper();
+ /// return uppercase of *this
+ String upper_str() const;
- /// convert this to downcase
- String lower(); // & ??
+ /// return lowercase of *this
+ String lower_str() const;
/// return the "esrever" of *this
- String reversed() const;
+ String reversed_str() const;
- /// return a piece starting at pos (first char = pos 1), ength n
- String mid(int pos, int n ) const;
+ /// return a piece starting at index_i (first char = index_i 0), length n
+ String mid_str(int index_i, int n ) const;
/// cut out a middle piece, return remainder
- String nomid(int pos, int n ) const;
+ String nomid_str(int index_i, int n ) const;
/// signed comparison, analogous to memcmp;
- static int compare(const String& s1,const String& s2);
+ static int compare_i(const String& s1,const String& s2);
/// index of rightmost c
- int lastPos( char c) const;
+ int index_last_i( char c) const;
/// index of rightmost element of string
- int lastPos( const char* string ) const;
+ int index_last_i( char const* string ) const;
/**
index of leftmost c.
@return
- 0 if not found, else index + 1
+ -1 if not found, else index
*/
- int pos(char c ) const;
- int pos(const char* string ) const;
- int posAny(const char* string ) const;
+ int index_i(char c ) const;
+ int index_i(char const* string ) const;
+ int index_any_i(char const* string ) const;
/// provide Stream output
- void printOn(ostream& os) const;
+ void print_on(ostream& os) const;
- /// convert to an integer
- long value() const;
-
- /// convert to a double
- double fvalue() const;
-
/// the length of the string
int length_i() const;
- // deprecated
+ // ***** depreciated
int len() const {
return length_i();
}
+ /// convert to an integer
+ int value_i() const;
+
+ /// convert to a double
+ double value_f() const;
+ // *****
};
#include "compare.hh"
-instantiate_compare(const String &, String::compare);
+instantiate_compare(const String &, String::compare_i);
-// because const char* also has an operator ==, this is for safety:
-inline bool operator==(String s1, const char *s2){
+// because char const* also has an operator ==, this is for safety:
+inline bool operator==(String s1, char const* s2){
return s1 == String(s2);
}
-inline bool operator==(const char *s1, String s2)
+inline bool operator==(char const* s1, String s2)
{
return String(s1)==s2;
}
-inline bool operator!=(String s1, const char *s2 ) {
+inline bool operator!=(String s1, char const* s2 ) {
return s1!=String(s2);
}
-inline bool operator!=(const char *s1,String s2) {
+inline bool operator!=(char const* s1,String s2) {
return String(s2) !=s1;
}
inline ostream &
operator << ( ostream& os, String d )
{
- d.printOn(os);
+ d.print_on(os);
return os;
}
-String quoteString(String message, String quote);
+// String quoteString(String message, String quote);
-#include "stringconversion.hh"
+#include "string-convert.hh"
#endif
+++ /dev/null
-/*
- PROJECT: FlowerSoft C++ library
- FILE : stringconversion.cc
-
---*/
-
-
-#include <assert.h>
-#include "string.hh"
-
-String
-StringConversion::bin2hex_str( String bin_str )
-{
- String str;
- Byte const* byte_c_l = bin_str.byte_c_l();
- for ( int i = 0; i < bin_str.length_i(); i++ ) {
- str += (char)nibble2hex_by( *byte_c_l >> 4 );
- str += (char)nibble2hex_by( *byte_c_l++ );
- }
- return str;
-}
-
-int
-StringConversion::bin2int_i( String bin_str )
-{
- assert( bin_str.length_i() <= 4 );
-
- int result_i = 0;
- for ( int i = 0; i < bin_str.length_i(); i++ ) {
- result_i <<= 8;
- result_i |= bin_str[ i ];
- }
- return result_i;
-}
-
-
-int
-StringConversion::hex2bin_i( String hex_str, String& bin_str_r )
-{
- if ( hex_str.length_i() % 2 )
- hex_str = "0" + hex_str;
-
- bin_str_r = "";
- Byte const* byte_c_l= hex_str.byte_c_l();
- int i = 0;
- while ( i < hex_str.length_i() ) {
- int high_i = hex2nibble_i( *byte_c_l++ );
- int low_i = hex2nibble_i( *byte_c_l++ );
- if ( high_i < 0 || low_i < 0 )
- return 1; // illegal char
- bin_str_r += String( (char)( high_i << 4 | low_i ), 1 );
- i += 2;
- }
- return 0;
-}
-
-String
-StringConversion::hex2bin_str( String hex_str )
-{
- String str;
-// silly, asserts should alway be "on"!
-// assert( !hex2bin_i( hex_str, str ) );
- int error_i = hex2bin_i( hex_str, str );
- assert( !error_i );
- return str;
-}
-
-int
-StringConversion::hex2nibble_i( Byte by )
-{
- if ( by >= '0' && by <= '9' )
- return by - '0';
- if ( by >= 'A' && by <= 'F' )
- return by - 'A' + 10;
- if ( by >= 'a' && by <= 'f')
- return by - 'a' + 10;
- return -1;
-}
-
-String
-StringConversion::int2hex_str( int i, int length_i, char ch )
-{
- String str;
- if ( !i )
- str = "0";
- while ( i ) {
- str = ( i % 16 )["0123456789abcdef"] + str;
- i /= 16;
- }
- if ( str.length_i() < length_i )
- str = String( ch, length_i - str.length_i() ) + str;
- return str;
-}
-
-Byte
-StringConversion::nibble2hex_by( Byte by )
-{
- if ( ( by & 0x0f ) <= 9 )
- return ( by & 0x0f ) + '0';
- else
- return ( by & 0x0f ) - 10 + 'a';
-}
+++ /dev/null
-/*
- PROJECT: FlowerSoft C++ library
- FILE : stringconversion.hh
-
-*/
-
-#ifndef STRING_CONVERSION_HH
-#define STRING_CONVERSION_HH
-
-/**
- all conversions from/to String go in here.( some time, anyway )
- The class is quite empty from data view.
- */
-class StringConversion {
- static int hex2bin_i( String hex_str, String& bin_str_r );
- static int hex2nibble_i( Byte by );
- static Byte nibble2hex_by( Byte by );
-public:
- static String bin2dec_str( String dec_str );
- static String bin2hex_str( String bin_str );
- static String dec2bin_str( String str );
- static int bin2int_i( String str );
- static int dec2int_i( String str );
- static int hex2int_i( String str );
- static String hex2bin_str( String str );
- static String int2hex_str( int i, int length_i, char ch );
- static String int2dec_str( int i, int length_i, char ch );
-};
-
-#endif // __STRING_CONVERSION_HH //
String str( "hai" );
cout << str << endl;
cout << "left" << endl;
- cout << " 0:" << str.left( 0 ) << endl;
- cout << " 1:" << str.left( 1 ) << endl;
- cout << " 2:" << str.left( 2 ) << endl;
- cout << " 3:" << str.left( 3 ) << endl;
- cout << " 4:" << str.left( 4 ) << endl;
+ cout << " 0:" << str.left_str( 0 ) << endl;
+ cout << " 1:" << str.left_str( 1 ) << endl;
+ cout << " 2:" << str.left_str( 2 ) << endl;
+ cout << " 3:" << str.left_str( 3 ) << endl;
+ cout << " 4:" << str.left_str( 4 ) << endl;
cout << "right" << endl;
- cout << " 0:" << str.right( 0 ) << endl;
- cout << " 1:" << str.right( 1 ) << endl;
- cout << " 2:" << str.right( 2 ) << endl;
- cout << " 3:" << str.right( 3 ) << endl;
- cout << " 4:" << str.right( 4 ) << endl;
+ cout << " 0:" << str.right_str( 0 ) << endl;
+ cout << " 1:" << str.right_str( 1 ) << endl;
+ cout << " 2:" << str.right_str( 2 ) << endl;
+ cout << " 3:" << str.right_str( 3 ) << endl;
+ cout << " 4:" << str.right_str( 4 ) << endl;
str += " daar";
cout << str << endl;
fn = "";
fn += "";
- delete fn.copy_by_p();
+ delete fn.copy_byte_p();
- delete str.copy_by_p();
+ delete str.copy_byte_p();
- cout << StringConversion::bin2hex_str( String( (char)0xff ) ) << endl;
+ cout << String_convert::bin2hex_str( String( (char)0xff ) ) << endl;
}