-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstring_impl.cpp
More file actions
34 lines (28 loc) · 855 Bytes
/
string_impl.cpp
File metadata and controls
34 lines (28 loc) · 855 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright 2012 Florian Petran
#include"string_impl.h"
#ifdef USE_ICU_STRING
#include<string>
#include<ostream>
const char* to_cstr(const string_impl& str) {
// one problem with this function:
// it returns a char ptr, so if i call it
// twice, both char ptr will have the value
// of the second call. might be fixable by
// making the ptr non static, but idk what
// that will do to performance.
static char out[256];
out[str.extract(0, 99, out)] = 0;
return out;
}
std::ostream& operator<<(std::ostream& strm, const string_impl& ustr) {
std::string str = to_cstr(ustr);
strm << str;
return strm;
}
#endif // USE_ICU_STRING
bool has_alpha(const string_impl& str) {
for (string_size i = 0; i < str.length(); ++i)
if (check_if_alpha(str[i]))
return true;
return false;
}