181
188
vector<string>* result);
183
190
// ----------------------------------------------------------------------
192
// Split a string using a character delimiter.
193
// ----------------------------------------------------------------------
194
inline vector<string> Split(
195
const string& full, const char* delim, bool skip_empty = true) {
196
vector<string> result;
198
SplitStringUsing(full, delim, &result);
200
SplitStringAllowEmpty(full, delim, &result);
205
// ----------------------------------------------------------------------
185
207
// These methods concatenate a vector of strings into a C++ string, using
186
208
// the C-string "delim" as a separator between components. There are two
454
485
static const int kFloatToBufferSize = 24;
456
487
// ----------------------------------------------------------------------
458
// Exactly like strtod(), except it always behaves as if in the "C"
459
// locale (i.e. decimal points must be '.'s).
460
// ----------------------------------------------------------------------
462
LIBPROTOBUF_EXPORT double NoLocaleStrtod(const char* text, char** endptr);
488
// ToString() are internal help methods used in StrCat() and Join()
489
// ----------------------------------------------------------------------
491
inline string ToString(int i) {
492
return SimpleItoa(i);
495
inline string ToString(string a) {
498
} // namespace internal
500
// ----------------------------------------------------------------------
502
// These methods join some strings together.
503
// ----------------------------------------------------------------------
504
template <typename T1, typename T2, typename T3, typename T4, typename T5>
506
const T1& a, const T2& b, const T3& c, const T4& d, const T5& e) {
507
return internal::ToString(a) + internal::ToString(b) +
508
internal::ToString(c) + internal::ToString(d) + internal::ToString(e);
511
template <typename T1, typename T2, typename T3, typename T4>
513
const T1& a, const T2& b, const T3& c, const T4& d) {
514
return internal::ToString(a) + internal::ToString(b) +
515
internal::ToString(c) + internal::ToString(d);
518
template <typename T1, typename T2, typename T3>
519
string StrCat(const T1& a, const T2& b, const T3& c) {
520
return internal::ToString(a) + internal::ToString(b) +
521
internal::ToString(c);
524
template <typename T1, typename T2>
525
string StrCat(const T1& a, const T2& b) {
526
return internal::ToString(a) + internal::ToString(b);
529
// ----------------------------------------------------------------------
531
// These methods concatenate a range of components into a C++ string, using
532
// the C-string "delim" as a separator between components.
533
// ----------------------------------------------------------------------
534
template <typename Iterator>
535
void Join(Iterator start, Iterator end,
536
const char* delim, string* result) {
537
for (Iterator it = start; it != end; ++it) {
539
result->append(delim);
541
result->append(internal::ToString(*it));
545
template <typename Range>
546
string Join(const Range& components,
549
Join(components.begin(), components.end(), delim, &result);
553
// ----------------------------------------------------------------------
555
// Return a lower-case hex string representation of the given integer.
556
// ----------------------------------------------------------------------
557
LIBPROTOBUF_EXPORT string ToHex(uint64 num);
464
559
} // namespace protobuf
465
560
} // namespace google