diff options
author | Mike Buland <eichlan@xagasoft.com> | 2009-08-13 05:56:57 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2009-08-13 05:56:57 +0000 |
commit | 8e49d2335332b3b97b516c9e00c5235d4f13f03e (patch) | |
tree | 8d1967c7f2716300fc7641c3958b40989aa3039a /src | |
parent | cb219e9b51f3436b9fb6d63a2c7a05333e4c86ed (diff) | |
download | libbu++-8e49d2335332b3b97b516c9e00c5235d4f13f03e.tar.gz libbu++-8e49d2335332b3b97b516c9e00c5235d4f13f03e.tar.bz2 libbu++-8e49d2335332b3b97b516c9e00c5235d4f13f03e.tar.xz libbu++-8e49d2335332b3b97b516c9e00c5235d4f13f03e.zip |
Bu::FString now has some fun conversion operators, you can do:
X << strVar;
where X is any primitive, and strVar is an FString. We'll add other
converters later, but it's fun so far.
Diffstat (limited to '')
-rw-r--r-- | src/fstring.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/fstring.cpp b/src/fstring.cpp index c9861e0..ce5492b 100644 --- a/src/fstring.cpp +++ b/src/fstring.cpp | |||
@@ -60,55 +60,55 @@ uint8_t &Bu::operator<<( uint8_t &dst, const Bu::FString &sIn ) | |||
60 | return dst; | 60 | return dst; |
61 | } | 61 | } |
62 | 62 | ||
63 | int8_t &operator<<( int8_t &dst, const Bu::FString &sIn ) | 63 | int8_t &Bu::operator<<( int8_t &dst, const Bu::FString &sIn ) |
64 | { | 64 | { |
65 | sscanf( sIn.getStr(), "%hhd", &dst ); | 65 | sscanf( sIn.getStr(), "%hhd", &dst ); |
66 | return dst; | 66 | return dst; |
67 | } | 67 | } |
68 | 68 | ||
69 | char &operator<<( char &dst, const Bu::FString &sIn ) | 69 | char &Bu::operator<<( char &dst, const Bu::FString &sIn ) |
70 | { | 70 | { |
71 | sscanf( sIn.getStr(), "%hhd", &dst ); | 71 | sscanf( sIn.getStr(), "%hhd", &dst ); |
72 | return dst; | 72 | return dst; |
73 | } | 73 | } |
74 | 74 | ||
75 | uint16_t &operator<<( uint16_t &dst, const Bu::FString &sIn ) | 75 | uint16_t &Bu::operator<<( uint16_t &dst, const Bu::FString &sIn ) |
76 | { | 76 | { |
77 | sscanf( sIn.getStr(), "%hu", &dst ); | 77 | sscanf( sIn.getStr(), "%hu", &dst ); |
78 | return dst; | 78 | return dst; |
79 | } | 79 | } |
80 | 80 | ||
81 | int16_t &operator<<( int16_t &dst, const Bu::FString &sIn ) | 81 | int16_t &Bu::operator<<( int16_t &dst, const Bu::FString &sIn ) |
82 | { | 82 | { |
83 | sscanf( sIn.getStr(), "%hd", &dst ); | 83 | sscanf( sIn.getStr(), "%hd", &dst ); |
84 | return dst; | 84 | return dst; |
85 | } | 85 | } |
86 | 86 | ||
87 | uint32_t &operator<<( uint32_t &dst, const Bu::FString &sIn ) | 87 | uint32_t &Bu::operator<<( uint32_t &dst, const Bu::FString &sIn ) |
88 | { | 88 | { |
89 | sscanf( sIn.getStr(), "%u", &dst ); | 89 | sscanf( sIn.getStr(), "%u", &dst ); |
90 | return dst; | 90 | return dst; |
91 | } | 91 | } |
92 | 92 | ||
93 | int32_t &operator<<( int32_t &dst, const Bu::FString &sIn ) | 93 | int32_t &Bu::operator<<( int32_t &dst, const Bu::FString &sIn ) |
94 | { | 94 | { |
95 | sscanf( sIn.getStr(), "%d", &dst ); | 95 | sscanf( sIn.getStr(), "%d", &dst ); |
96 | return dst; | 96 | return dst; |
97 | } | 97 | } |
98 | 98 | ||
99 | uint64_t &operator<<( uint64_t &dst, const Bu::FString &sIn ) | 99 | uint64_t &Bu::operator<<( uint64_t &dst, const Bu::FString &sIn ) |
100 | { | 100 | { |
101 | sscanf( sIn.getStr(), "%llu", &dst ); | 101 | sscanf( sIn.getStr(), "%llu", &dst ); |
102 | return dst; | 102 | return dst; |
103 | } | 103 | } |
104 | 104 | ||
105 | int64_t &operator<<( int64_t &dst, const Bu::FString &sIn ) | 105 | int64_t &Bu::operator<<( int64_t &dst, const Bu::FString &sIn ) |
106 | { | 106 | { |
107 | sscanf( sIn.getStr(), "%lld", &dst ); | 107 | sscanf( sIn.getStr(), "%lld", &dst ); |
108 | return dst; | 108 | return dst; |
109 | } | 109 | } |
110 | 110 | ||
111 | float &operator<<( float &dst, const Bu::FString &sIn ) | 111 | float &Bu::operator<<( float &dst, const Bu::FString &sIn ) |
112 | { | 112 | { |
113 | double tmp; | 113 | double tmp; |
114 | sscanf( sIn.getStr(), "%f", &tmp ); | 114 | sscanf( sIn.getStr(), "%f", &tmp ); |
@@ -116,19 +116,19 @@ float &operator<<( float &dst, const Bu::FString &sIn ) | |||
116 | return dst; | 116 | return dst; |
117 | } | 117 | } |
118 | 118 | ||
119 | double &operator<<( double &dst, const Bu::FString &sIn ) | 119 | double &Bu::operator<<( double &dst, const Bu::FString &sIn ) |
120 | { | 120 | { |
121 | sscanf( sIn.getStr(), "%f", &dst ); | 121 | sscanf( sIn.getStr(), "%f", &dst ); |
122 | return dst; | 122 | return dst; |
123 | } | 123 | } |
124 | 124 | ||
125 | long double &operator<<( long double &dst, const Bu::FString &sIn ) | 125 | long double &Bu::operator<<( long double &dst, const Bu::FString &sIn ) |
126 | { | 126 | { |
127 | sscanf( sIn.getStr(), "%Lf", &dst ); | 127 | sscanf( sIn.getStr(), "%Lf", &dst ); |
128 | return dst; | 128 | return dst; |
129 | } | 129 | } |
130 | 130 | ||
131 | Bu::FString &operator<<( Bu::FString &dst, const Bu::FString &sIn ) | 131 | Bu::FString &Bu::operator<<( Bu::FString &dst, const Bu::FString &sIn ) |
132 | { | 132 | { |
133 | dst = sIn; | 133 | dst = sIn; |
134 | return dst; | 134 | return dst; |