33 #ifndef PROTOC_STRUTIL_H_
34 #define PROTOC_STRUTIL_H_
36 #include <google/protobuf/stubs/common.h>
47 #define strtoll _strtoi64
48 #define strtoull _strtoui64
49 #elif defined(__DECCXX) && defined(__osf__)
51 #define strtoll strtol
52 #define strtoull strtoul
65 inline bool ascii_isalnum(
char c) {
66 return (
'a' <= c && c <=
'z') ||
67 (
'A' <= c && c <=
'Z') ||
68 (
'0' <= c && c <=
'9');
71 inline bool ascii_isdigit(
char c) {
72 return (
'0' <= c && c <=
'9');
83 inline bool HasSuffixString(
const string& str,
84 const string& suffix) {
85 return str.size() >= suffix.size() &&
86 str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0;
89 inline string StripSuffixString(
const string& str,
const string& suffix) {
90 if (HasSuffixString(str, suffix)) {
91 return str.substr(0, str.size() - suffix.size());
105 LIBPROTOBUF_EXPORT
string StringReplace(
const string& s,
const string& oldsub,
106 const string& newsub,
bool replace_all);
114 LIBPROTOBUF_EXPORT
void SplitStringUsing(
const string& full,
const char* delim,
115 vector<string>* res);
141 static const int kFastToBufferSize = 32;
143 LIBPROTOBUF_EXPORT
char* FastInt32ToBuffer(int32_t i,
char* buffer);
144 LIBPROTOBUF_EXPORT
char* FastInt64ToBuffer(int64_t i,
char* buffer);
145 char* FastUInt32ToBuffer(uint32_t i,
char* buffer);
146 char* FastUInt64ToBuffer(uint64_t i,
char* buffer);
147 LIBPROTOBUF_EXPORT
char* FastHexToBuffer(
int i,
char* buffer);
148 LIBPROTOBUF_EXPORT
char* FastHex64ToBuffer(uint64_t i,
char* buffer);
149 LIBPROTOBUF_EXPORT
char* FastHex32ToBuffer(uint32_t i,
char* buffer);
167 LIBPROTOBUF_EXPORT
char* FastInt32ToBufferLeft(int32_t i,
char* buffer);
168 LIBPROTOBUF_EXPORT
char* FastUInt32ToBufferLeft(uint32_t i,
char* buffer);
169 LIBPROTOBUF_EXPORT
char* FastInt64ToBufferLeft(int64_t i,
char* buffer);
170 LIBPROTOBUF_EXPORT
char* FastUInt64ToBufferLeft(uint64_t i,
char* buffer);
173 inline char* FastUInt32ToBuffer(uint32_t i,
char* buffer) {
174 FastUInt32ToBufferLeft(i, buffer);
177 inline char* FastUInt64ToBuffer(uint64_t i,
char* buffer) {
178 FastUInt64ToBufferLeft(i, buffer);
188 LIBPROTOBUF_EXPORT
string SimpleItoa(
int i);
189 LIBPROTOBUF_EXPORT
string SimpleItoa(
unsigned int i);
190 LIBPROTOBUF_EXPORT
string SimpleItoa(
long i);
191 LIBPROTOBUF_EXPORT
string SimpleItoa(
unsigned long i);
192 LIBPROTOBUF_EXPORT
string SimpleItoa(
long long i);
193 LIBPROTOBUF_EXPORT
string SimpleItoa(
194 unsigned long long i);
198 #endif // PROTOC_STRUTIL_H_