Browse Source

Adding SimpleItoa(int64).

pull/567/head
Philip Liard 15 years ago
committed by Mihaela Rosca
parent
commit
d4e1c73375
2 changed files with 15 additions and 2 deletions
  1. +11
    -1
      cpp/src/stringutil.cc
  2. +4
    -1
      cpp/src/stringutil.h

+ 11
- 1
cpp/src/stringutil.cc View File

@ -35,7 +35,8 @@ string operator+(const string& s, int n) {
return result; return result;
} }
string SimpleItoa(int n) {
template <typename T>
string GenericSimpleItoa(const T& n) {
stringstream ss; stringstream ss;
ss << n; ss << n;
@ -45,6 +46,15 @@ string SimpleItoa(int n) {
return result; return result;
} }
string SimpleItoa(int n) {
return GenericSimpleItoa(n);
}
string SimpleItoa(uint64 n) {
return GenericSimpleItoa(n);
}
bool TryStripPrefixString(const string& in, const string& prefix, string* out) { bool TryStripPrefixString(const string& in, const string& prefix, string* out) {
assert(out); assert(out);
const bool has_prefix = in.compare(0, prefix.length(), prefix) == 0; const bool has_prefix = in.compare(0, prefix.length(), prefix) == 0;


+ 4
- 1
cpp/src/stringutil.h View File

@ -20,6 +20,8 @@
#include <cstddef> #include <cstddef>
#include <string> #include <string>
#include <base/basictypes.h>
namespace i18n { namespace i18n {
namespace phonenumbers { namespace phonenumbers {
@ -28,7 +30,8 @@ using std::string;
// Support string("hello") + 10 // Support string("hello") + 10
string operator+(const string& s, int n); string operator+(const string& s, int n);
// Convert integer into string
// Convert integer to string.
string SimpleItoa(uint64 n);
string SimpleItoa(int n); string SimpleItoa(int n);
// Return true if 'in' starts with 'prefix' and write into 'out' // Return true if 'in' starts with 'prefix' and write into 'out'


Loading…
Cancel
Save