aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/fbasicstring.h21
-rw-r--r--src/fstring.cpp90
-rw-r--r--src/fstring.h16
3 files changed, 127 insertions, 0 deletions
diff --git a/src/fbasicstring.h b/src/fbasicstring.h
index fbfc5ef..33a82cb 100644
--- a/src/fbasicstring.h
+++ b/src/fbasicstring.h
@@ -1226,6 +1226,19 @@ namespace Bu
1226 append( s, e ); 1226 append( s, e );
1227 } 1227 }
1228 1228
1229 /**
1230 * Resize the string, possibly to make room for a copy. At the moment
1231 * this operation *is* destructive. What was in the string will in no
1232 * way be preserved.
1233 *@param iSize the new size in bytes. The string is guranteed to have
1234 * at least this much contiguous space available when done.
1235 */
1236 void setSize( long iSize )
1237 {
1238 clear();
1239 appendChunk( newChunk( iSize ) );
1240 }
1241
1229 void expand() 1242 void expand()
1230 { 1243 {
1231 flatten(); 1244 flatten();
@@ -1520,6 +1533,14 @@ namespace Bu
1520 } 1533 }
1521 } 1534 }
1522 1535
1536// template<typename out>
1537// void to( out &dst );
1538/* {
1539 flatten();
1540
1541 dst = strtol( pFirst->pData, NULL, 0 );
1542 } */
1543
1523 const_iterator find( const chr cChar, 1544 const_iterator find( const chr cChar,
1524 const_iterator iStart=typename MyType::const_iterator() ) const 1545 const_iterator iStart=typename MyType::const_iterator() ) const
1525 { 1546 {
diff --git a/src/fstring.cpp b/src/fstring.cpp
index e4dc716..c9861e0 100644
--- a/src/fstring.cpp
+++ b/src/fstring.cpp
@@ -44,3 +44,93 @@ template<> void Bu::__tracer_format<Bu::FString>( const Bu::FString &v )
44 printf("(%ld)\"%s\"", v.getSize(), v.getStr() ); 44 printf("(%ld)\"%s\"", v.getSize(), v.getStr() );
45} 45}
46 46
47bool &Bu::operator<<( bool &dst, const Bu::FString &sIn )
48{
49 if( sIn == "true" || sIn == "yes" || sIn == "t" )
50 dst = true;
51 else
52 dst = false;
53
54 return dst;
55}
56
57uint8_t &Bu::operator<<( uint8_t &dst, const Bu::FString &sIn )
58{
59 sscanf( sIn.getStr(), "%hhu", &dst );
60 return dst;
61}
62
63int8_t &operator<<( int8_t &dst, const Bu::FString &sIn )
64{
65 sscanf( sIn.getStr(), "%hhd", &dst );
66 return dst;
67}
68
69char &operator<<( char &dst, const Bu::FString &sIn )
70{
71 sscanf( sIn.getStr(), "%hhd", &dst );
72 return dst;
73}
74
75uint16_t &operator<<( uint16_t &dst, const Bu::FString &sIn )
76{
77 sscanf( sIn.getStr(), "%hu", &dst );
78 return dst;
79}
80
81int16_t &operator<<( int16_t &dst, const Bu::FString &sIn )
82{
83 sscanf( sIn.getStr(), "%hd", &dst );
84 return dst;
85}
86
87uint32_t &operator<<( uint32_t &dst, const Bu::FString &sIn )
88{
89 sscanf( sIn.getStr(), "%u", &dst );
90 return dst;
91}
92
93int32_t &operator<<( int32_t &dst, const Bu::FString &sIn )
94{
95 sscanf( sIn.getStr(), "%d", &dst );
96 return dst;
97}
98
99uint64_t &operator<<( uint64_t &dst, const Bu::FString &sIn )
100{
101 sscanf( sIn.getStr(), "%llu", &dst );
102 return dst;
103}
104
105int64_t &operator<<( int64_t &dst, const Bu::FString &sIn )
106{
107 sscanf( sIn.getStr(), "%lld", &dst );
108 return dst;
109}
110
111float &operator<<( float &dst, const Bu::FString &sIn )
112{
113 double tmp;
114 sscanf( sIn.getStr(), "%f", &tmp );
115 dst = tmp;
116 return dst;
117}
118
119double &operator<<( double &dst, const Bu::FString &sIn )
120{
121 sscanf( sIn.getStr(), "%f", &dst );
122 return dst;
123}
124
125long double &operator<<( long double &dst, const Bu::FString &sIn )
126{
127 sscanf( sIn.getStr(), "%Lf", &dst );
128 return dst;
129}
130
131Bu::FString &operator<<( Bu::FString &dst, const Bu::FString &sIn )
132{
133 dst = sIn;
134 return dst;
135}
136
diff --git a/src/fstring.h b/src/fstring.h
index 0793154..1fc02ca 100644
--- a/src/fstring.h
+++ b/src/fstring.h
@@ -20,6 +20,22 @@ namespace Bu
20 20
21 template<typename t> void __tracer_format( const t &v ); 21 template<typename t> void __tracer_format( const t &v );
22 template<> void __tracer_format<FString>( const FString &v ); 22 template<> void __tracer_format<FString>( const FString &v );
23
24 bool &operator<<( bool &dst, const FString &sIn );
25 uint8_t &operator<<( uint8_t &dst, const FString &sIn );
26 int8_t &operator<<( int8_t &dst, const FString &sIn );
27 char &operator<<( char &dst, const FString &sIn );
28 uint16_t &operator<<( uint16_t &dst, const FString &sIn );
29 int16_t &operator<<( int16_t &dst, const FString &sIn );
30 uint32_t &operator<<( uint32_t &dst, const FString &sIn );
31 int32_t &operator<<( int32_t &dst, const FString &sIn );
32 uint64_t &operator<<( uint64_t &dst, const FString &sIn );
33 int64_t &operator<<( int64_t &dst, const FString &sIn );
34 float &operator<<( float &dst, const FString &sIn );
35 double &operator<<( double &dst, const FString &sIn );
36 long double &operator<<( long double &dst, const FString &sIn );
37 Bu::FString &operator<<( Bu::FString &dst, const FString &sIn );
38
23} 39}
24 40
25/***** I dunno about this block, I don't really want to have it... ***** 41/***** I dunno about this block, I don't really want to have it... *****