0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
StringExt.h
Go to the documentation of this file.
1 /* -*- c++ -*-
2  * Copyright (C) 2007-2015 Hypertable, Inc.
3  *
4  * This file is part of Hypertable.
5  *
6  * Hypertable is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 3
9  * of the License, or any later version.
10  *
11  * Hypertable is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA.
20  */
21 
26 #ifndef Common_StringExt_h
27 #define Common_StringExt_h
28 
29 #include <Common/String.h>
30 
31 #include <cstdio>
32 #include <set>
33 #include <map>
34 
39 using namespace Hypertable;
40 
42 typedef std::set<String> StringSet;
43 
45 struct LtCstr {
46  bool operator()(const char *s1, const char *s2) const {
47  return strcmp(s1, s2) < 0;
48  }
49 };
50 
52 typedef std::set<const char *, LtCstr> CstrSet;
53 
55 typedef std::map<const char *, int32_t, LtCstr> CstrToInt32Map;
56 
58 typedef std::map<const char *, int64_t, LtCstr> CstrToInt64MapT;
59 
61 inline String operator+(const String &s1, short sval) {
62  return s1 + Int16Formatter(sval).c_str();
63 }
64 
66 inline String operator+(const String &s1, uint16_t sval) {
67  return s1 + UInt16Formatter(sval).c_str();
68 }
69 
71 inline String operator+(const String &s1, int ival) {
72  return s1 + Int32Formatter(ival).c_str();
73 }
74 
76 inline String operator+(const String &s1, uint32_t ival) {
77  return s1 + UInt32Formatter(ival).c_str();
78 }
79 
81 inline String operator+(const String &s1, int64_t llval) {
82  return s1 + Int64Formatter(llval).c_str();
83 }
84 
86 inline String operator+(const String &s1, uint64_t llval) {
87  return s1 + UInt64Formatter(llval).c_str();
88 }
89 
92 #endif // Common_StringExt_h
std::set< String > StringSet
STL Set managing Strings.
Definition: StringExt.h:42
NumericUnsignedFormatter< uint32_t > UInt32Formatter
Definition: String.h:243
std::map< const char *, int64_t, LtCstr > CstrToInt64MapT
STL map from c-style string to int64_t.
Definition: StringExt.h:58
NumericSignedFormatter< int16_t > Int16Formatter
Definition: String.h:247
NumericSignedFormatter< int32_t > Int32Formatter
Definition: String.h:248
std::string String
A String is simply a typedef to std::string.
Definition: String.h:44
bool operator()(const char *s1, const char *s2) const
Definition: StringExt.h:46
std::set< const char *, LtCstr > CstrSet
STL Set managing c-style strings.
Definition: StringExt.h:52
NumericUnsignedFormatter< uint16_t > UInt16Formatter
Definition: String.h:242
STL Strict Weak Ordering for comparing c-style strings.
Definition: StringExt.h:45
Hypertable definitions
NumericSignedFormatter< int64_t > Int64Formatter
Definition: String.h:249
NumericUnsignedFormatter< uint64_t > UInt64Formatter
Definition: String.h:244
A String class based on std::string.
String operator+(const String &s1, short sval)
Append operator for shorts.
Definition: StringExt.h:61
std::map< const char *, int32_t, LtCstr > CstrToInt32Map
STL map from c-style string to int32_t.
Definition: StringExt.h:55