24 #ifndef LOG4CPLUS_HELPERS_STRINGHELPER_HEADER_
25 #define LOG4CPLUS_HELPERS_STRINGHELPER_HEADER_
29 #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
69 template <
class StringType,
class OutputIter>
72 tokenize(
const StringType& s,
typename StringType::value_type c,
73 OutputIter result,
bool collapseTokens =
true)
75 typedef typename StringType::size_type size_type;
76 size_type
const slen = s.length();
79 for (i=0; i < slen; ++i)
83 *result = StringType (s, first, i - first);
86 while (i+1 < slen && s[i+1] == c)
92 *result = StringType (s, first, i - first);
93 else if (! collapseTokens && first == i)
94 *result = StringType ();
98 template <
typename intType,
typename stringType,
bool isSigned>
102 template <
typename intType,
typename charType>
107 step1 (charType * & it, intType & value)
117 value == (std::numeric_limits<intType>::min) ()))
119 intType
const r = value / 10;
120 intType
const a = (-r) * 10;
121 intType
const mod = -(a + value);
141 template <
typename intType,
typename charType>
160 template <
class stringType,
class intType>
165 typedef std::numeric_limits<intType> intTypeLimits;
166 typedef typename stringType::value_type charType;
168 intTypeLimits::is_signed> HelperType;
170 charType buffer[intTypeLimits::digits10 + 2];
171 const std::size_t buffer_size
172 =
sizeof (buffer) /
sizeof (charType);
174 charType * it = &buffer[buffer_size];
175 charType
const *
const buf_end = &buffer[buffer_size];
184 bool const negative = HelperType::is_negative (value);
186 HelperType::step1 (it, value);
188 for (; value != 0; --it)
190 intType mod = value % 10;
203 str.assign (
static_cast<charType
const *
>(it), buf_end);
207 template<
class intType>
218 template<
class intType>
230 template <
typename Iterator,
typename Separator>
234 Separator
const & sep)
239 for (; start != last; ++start)
247 template <
typename Iterator>
257 template <
typename Iterator>
261 tstring::value_type sep)
#define LOG4CPLUS_TEXT(STRING)
#define LOG4CPLUS_UNLIKELY(cond)
LOG4CPLUS_EXPORT log4cplus::tstring toUpper(const log4cplus::tstring &s)
Returns s in upper case.
void join_worker(tstring &result, Iterator &start, Iterator &last, Separator const &sep)
Join a list of items into a string.
void join(tstring &result, Iterator start, Iterator last, tstring const &sep)
Join a list of items into a string.
void convertIntegerToString(stringType &str, intType value)
void tokenize(const StringType &s, typename StringType::value_type c, OutputIter result, bool collapseTokens=true)
Tokenize s using c as the delimiter and put the resulting tokens in _result.
std::string convertIntegerToNarrowString(intType value)
LOG4CPLUS_EXPORT log4cplus::tstring toLower(const log4cplus::tstring &s)
Returns s in lower case.
std::basic_string< tchar > tstring
static void step1(charType *&, intType &)
static bool is_negative(intType)
static bool is_negative(intType val)
static void step1(charType *&it, intType &value)