001:
002:
003:
004:
005:
006:
007:
008:
009:
010:
011:
012:
013:
014:
015:
016:
017:
018:
019:
020:
021:
022:
023:
024:
025:
026:
027:
028:
029:
030:
031:
032:
033:
034:
035:
036:
037:
038:
039:
040:
041:
042:
043:
044:
045:
046:
047:
048:
049:
050:
051:
052:
053:
054:
055:
056:
057:
058:
059:
060:
061:
062:
063:
064:
065:
066:
067:
068:
069:
070:
071:
072:
073:
074:
075:
076:
077:
078:
079:
080:
081:
082:
083:
084:
085:
086:
087:
088:
089:
090:
091:
092:
093:
094:
095:
096:
097:
098:
099:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
314:
315:
316:
317:
318:
319:
320:
321:
322:
323:
324:
325:
326:
327:
328:
329:
330:
331:
332:
333:
334:
335:
336:
337:
338:
339:
340:
341:
342:
343:
344:
345:
346:
347:
348:
349:
350:
351:
352:
353:
354:
355:
356:
357:
358:
359:
360:
361:
362:
363:
364:
365:
366:
367:
368:
369:
370:
371:
372:
373:
374:
375:
376:
377:
378:
379:
380:
381:
382:
383:
384:
385:
386:
387:
388:
389:
390:
391:
392:
393:
394:
395:
396:
397:
398:
399:
400:
401:
402:
403:
404:
405:
406:
407:
408:
409:
410:
411:
412:
413:
414:
415:
416:
417:
418:
419:
420:
421:
422:
423:
424:
425:
426:
427:
428:
429:
430:
431:
432:
433:
434:
435:
436:
437:
438:
439:
440:
























































































































































































































































































































































































































































/*
* This file is part of the Omni C++ framework
*
* Copyright (c) 2016, Zeriph Enterprises, LLC
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of Zeriph, Zeriph Enterprises, LLC, nor the names
* of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY ZERIPH AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL ZERIPH AND CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

/* DEV_NOTE: this file is not intended to be used directly by any user code!

i.e. don't #include <omni/xxx_impl.hxx> and don't compile this source directly.
this file is #include'd directly in other source.

The logic is that omni::cstring and omni::wstring namespaces segregate the types
for explicit calling; i.e. you can call omni::cstring::X to check on a std:string
and similarly can call omni::wstring::X to check a std::wstring, while still having access
to the omni::string_t and omn::string::X functions (which are aliases for the other namespaces).

Since omni::wstring and omni::cstring are merely wrappers for the omni::string::util functions
(which are templated) that then pass in the appropriate types (std::string/wstring char/wchar_t)
putting the relevant code in a header with a few #defs for types makes keeping the files
in sync (for functions) less messy. It does introduce slight confusion to anyone who might
want to read this specific code or documentation though, hence this note.
*/

// so as not to accidentally build this file with the source
// these macros are defined in string/util.hpp string/cstring.hpp and string/wstring.hpp
#if !defined(OMNI_CHAR_T_FW) || !defined(OMNI_STRING_T_FW)
    #error invalid preprocessor directive detected
#endif

// namespace omni::string/cstring/wstring {

namespace binary {
    inline bool is_valid(const OMNI_STRING_T_FW& str)
    {
        return omni::string::util::binary::is_valid<OMNI_STRING_T_FW>(str);
    }
    
    inline OMNI_STRING_T_FW from_uint(unsigned int val, bool trim)
    {
        return omni::string::util::binary::from_uint<OMNI_STRING_T_FW>(val, trim);
    }
    
    inline OMNI_STRING_T_FW from_uint(unsigned int val)
    {
        return omni::string::util::binary::from_uint<OMNI_STRING_T_FW>(val, true);
    }
    
    inline OMNI_STRING_T_FW from_ulong(unsigned long val, bool trim)
    {
        return omni::string::util::binary::from_ulong<OMNI_STRING_T_FW>(val, trim);
    }
    
    inline OMNI_STRING_T_FW from_ulong(unsigned long val)
    {
        return omni::string::util::binary::from_ulong<OMNI_STRING_T_FW>(val, true);
    }
    
    inline unsigned int to_uint(const OMNI_STRING_T_FW& str)
    {
        return omni::string::util::binary::to_uint(str);
    }
    
    inline unsigned long to_ulong(const OMNI_STRING_T_FW& str)
    {
        return omni::string::util::binary::to_ulong(str);
    }
    
    inline std::size_t to_size_t(const OMNI_STRING_T_FW& str)
    {
        return omni::string::util::binary::to_size_t(str);
    }
}

inline bool contains(const OMNI_STRING_T_FW& chk, const OMNI_STRING_T_FW& fnd, bool ignoreCase)
{
    return omni::string::util::contains(chk, fnd, ignoreCase);
}

inline bool contains(const OMNI_STRING_T_FW& chk, const OMNI_STRING_T_FW& fnd)
{
    return omni::string::util::contains(chk, fnd, false);
}

inline bool is_numeric(const OMNI_STRING_T_FW& str, bool ignorePeriod)
{
    return omni::string::util::is_numeric(str, ignorePeriod);
}

inline bool is_numeric(const OMNI_CHAR_T_FW* str, bool ignorePeriod)
{
    return omni::string::util::is_numeric(str, ignorePeriod);
}

template < std::size_t X >
inline bool is_numeric(const OMNI_CHAR_T_FW (&str)[X], bool ignorePeriod)
{
    return omni::string::util::is_numeric(OMNI_STRING_T_FW(str), ignorePeriod);
}

inline bool is_numeric(const OMNI_STRING_T_FW& str)
{
    return omni::string::util::is_numeric(str, false);
}

inline bool is_numeric(const OMNI_CHAR_T_FW* str)
{
    return omni::string::util::is_numeric(str, false);
}

template < std::size_t X >
inline bool is_numeric(const OMNI_CHAR_T_FW (&str)[X])
{
    return omni::string::util::is_numeric(OMNI_STRING_T_FW(str), false);
}

inline OMNI_STRING_T_FW pad_left(OMNI_STRING_T_FW str, OMNI_CHAR_T_FW pad, std::size_t count)
{
    return omni::string::util::pad_left(str, pad, count);
}

inline OMNI_STRING_T_FW pad_left(OMNI_STRING_T_FW str, const OMNI_STRING_T_FW& pad, std::size_t count)
{
    return omni::string::util::pad_left(str, pad, count);
}

template < std::size_t X >
inline OMNI_STRING_T_FW pad_left(OMNI_STRING_T_FW str, const OMNI_CHAR_T_FW (&pad)[X], std::size_t count)
{
    return omni::string::util::pad_left(str, pad);
}

inline OMNI_STRING_T_FW pad_right(OMNI_STRING_T_FW str, OMNI_CHAR_T_FW pad, std::size_t count)
{
    return omni::string::util::pad_right(str, pad, count);
}

inline OMNI_STRING_T_FW pad_right(OMNI_STRING_T_FW str, const OMNI_STRING_T_FW& pad, std::size_t count)
{
    return omni::string::util::pad_right(str, pad, count);
}

template < std::size_t X >
inline OMNI_STRING_T_FW pad_right(OMNI_STRING_T_FW str, const OMNI_CHAR_T_FW (&pad)[X], std::size_t count)
{
    return omni::string::util::pad_right(str, pad);
}

inline OMNI_STRING_T_FW replace(OMNI_STRING_T_FW str, const OMNI_STRING_T_FW& fnd, const OMNI_STRING_T_FW& newstr, std::size_t pos, bool ignoreCase)
{
    return omni::string::util::replace(str, fnd, newstr, pos, ignoreCase);
}

inline OMNI_STRING_T_FW replace(OMNI_STRING_T_FW str, const OMNI_STRING_T_FW& fnd, const OMNI_STRING_T_FW& newstr)
{
    return omni::string::util::replace(str, fnd, newstr, 0, false);
}

inline OMNI_STRING_T_FW replace(OMNI_STRING_T_FW str, const OMNI_STRING_T_FW& fnd, const OMNI_STRING_T_FW& newstr, bool ignoreCase)
{
    return omni::string::util::replace(str, fnd, newstr, 0, ignoreCase);
}

inline OMNI_STRING_T_FW replace(OMNI_STRING_T_FW str, const OMNI_STRING_T_FW& fnd, const OMNI_STRING_T_FW& newstr, std::size_t pos)
{
    return omni::string::util::replace(str, fnd, newstr, pos, false);
}

template < std::size_t X, std::size_t Y >
inline OMNI_STRING_T_FW replace(OMNI_STRING_T_FW str, const OMNI_CHAR_T_FW (&fnd)[X], const OMNI_CHAR_T_FW (&newstr)[Y], std::size_t pos)
{
    return omni::string::util::replace(str, fnd, newstr, pos);
}

inline OMNI_STRING_T_FW replace_all(OMNI_STRING_T_FW str, const OMNI_STRING_T_FW& fnd, const OMNI_STRING_T_FW& newstr, std::size_t pos, bool ignoreCase)
{
    return omni::string::util::replace_all(str, fnd, newstr, pos, ignoreCase);
}

inline OMNI_STRING_T_FW replace_all(OMNI_STRING_T_FW str, const OMNI_STRING_T_FW& fnd, const OMNI_STRING_T_FW& newstr)
{
    return omni::string::util::replace_all(str, fnd, newstr, 0, false);
}

inline OMNI_STRING_T_FW replace_all(OMNI_STRING_T_FW str, const OMNI_STRING_T_FW& fnd, const OMNI_STRING_T_FW& newstr, bool ignoreCase)
{
    return omni::string::util::replace_all(str, fnd, newstr, 0, ignoreCase);
}

inline OMNI_STRING_T_FW replace_all(OMNI_STRING_T_FW str, const OMNI_STRING_T_FW& fnd, const OMNI_STRING_T_FW& newstr, std::size_t pos)
{
    return omni::string::util::replace_all(str, fnd, newstr, pos, false);
}

template < std::size_t X, std::size_t Y >
inline OMNI_STRING_T_FW replace_all(OMNI_STRING_T_FW str, const OMNI_CHAR_T_FW (&fnd)[X], const OMNI_CHAR_T_FW (&newstr)[Y], std::size_t pos)
{
    return omni::string::util::replace_all(str, fnd, newstr, pos);
}

inline OMNI_STRING_T_FW reverse(const OMNI_STRING_T_FW& str)
{
    return omni::string::util::reverse(str);
}

template < std::size_t X >
inline OMNI_STRING_T_FW reverse(const OMNI_CHAR_T_FW (&str)[X])
{
    return omni::string::util::reverse(OMNI_STRING_T_FW(str));
}

template < template < class, class > class std_seq_t, class std_allocator_t >
std_seq_t<OMNI_STRING_T_FW, std_allocator_t> split(const OMNI_STRING_T_FW& str, const OMNI_STRING_T_FW& delimeter, std::size_t max_val)
{
    return omni::string::util::split< std_seq_t, OMNI_STRING_T_FW, std_allocator_t >(str, delimeter, max_val);
}

template < template < class, class > class std_seq_t >
inline std_seq_t<OMNI_STRING_T_FW, std::allocator<OMNI_STRING_T_FW> > split(const OMNI_STRING_T_FW& str, const OMNI_STRING_T_FW& delimeter, std::size_t max_val)
{
    return omni::string::util::split< std_seq_t, OMNI_STRING_T_FW, std::allocator<OMNI_STRING_T_FW> >(str, delimeter, max_val);
}

inline OMNI_SEQ_T<OMNI_STRING_T_FW> split(const OMNI_STRING_T_FW& str, const OMNI_STRING_T_FW& delimeter, std::size_t max)
{
    return omni::string::util::split(str, delimeter, max);
}

inline OMNI_SEQ_T<OMNI_STRING_T_FW> split(const OMNI_STRING_T_FW& str, const OMNI_STRING_T_FW& delimeter)
{
    return omni::string::util::split(str, delimeter, 0);
}

inline OMNI_STRING_T_FW to_lower(OMNI_STRING_T_FW str)
{
    return omni::string::util::to_lower(str);
}

inline OMNI_STRING_T_FW to_upper(OMNI_STRING_T_FW str)
{
    return omni::string::util::to_upper(str);
}

template < typename T >
inline std::string to_string(const T& val)
{
    return omni::string::util::to_string(val);
}

inline std::string to_string(const std::string& str)
{
    return str;
}

inline std::string to_string(const char* str)
{
    return std::string(str);
}

template < std::size_t X >
inline std::string to_string(const char (&str)[X])
{
    return std::string(str);
}

template < typename T >
inline std::wstring to_wstring(const T& val)
{
    return omni::string::util::to_wstring(val);
}

inline std::wstring to_wstring(const std::wstring& str)
{
    return str;
}

inline std::wstring to_wstring(const wchar_t* str)
{
    return std::wstring(str);
}

template < std::size_t X >
inline std::wstring to_wstring(const wchar_t (&str)[X])
{
    return std::wstring(str);
}

template < typename T >
inline omni::string_t to_string_t(const T& val)
{
    return omni::string::util::to_string_t(val);
}

inline omni::string_t to_string_t(const omni::string_t& val)
{
    return val;
}

inline OMNI_STRING_T_FW trim(OMNI_STRING_T_FW str)
{
    return omni::string::util::trim(str);
}

inline OMNI_STRING_T_FW trim(OMNI_STRING_T_FW str, OMNI_CHAR_T_FW param)
{
    return omni::string::util::trim(str, param);
}

inline OMNI_STRING_T_FW trim(OMNI_STRING_T_FW str, OMNI_STRING_T_FW params)
{
    return omni::string::util::trim(str, params);
}

inline OMNI_STRING_T_FW trim(OMNI_STRING_T_FW str, OMNI_SEQ_T<OMNI_CHAR_T_FW>& params)
{
    return omni::string::util::trim(str, params.begin(), params.end());
}

template < std::size_t X >
inline OMNI_STRING_T_FW trim(OMNI_STRING_T_FW str, const OMNI_CHAR_T_FW (&params)[X])
{
    return omni::string::util::trim(str, OMNI_STRING_T_FW(params));
}

inline OMNI_STRING_T_FW trim_end(OMNI_STRING_T_FW str)
{
    return omni::string::util::trim_end(str);
}

inline OMNI_STRING_T_FW trim_end(OMNI_STRING_T_FW str, OMNI_CHAR_T_FW param)
{
    return omni::string::util::trim_end(str, param);
}

inline OMNI_STRING_T_FW trim_end(OMNI_STRING_T_FW str, OMNI_STRING_T_FW params)
{
    return omni::string::util::trim_end(str, params);
}

inline OMNI_STRING_T_FW trim_end(OMNI_STRING_T_FW str, OMNI_SEQ_T<OMNI_CHAR_T_FW>& params)
{
    return omni::string::util::trim_end(str, params.begin(), params.end());
}

template < std::size_t X >
inline OMNI_STRING_T_FW trim_end(OMNI_STRING_T_FW str, const OMNI_CHAR_T_FW (&params)[X])
{
    return omni::string::util::trim_end(str, OMNI_STRING_T_FW(params));
}

inline OMNI_STRING_T_FW trim_front(OMNI_STRING_T_FW str)
{
    return omni::string::util::trim_front(str);
}

inline OMNI_STRING_T_FW trim_front(OMNI_STRING_T_FW str, OMNI_CHAR_T_FW param)
{
    return omni::string::util::trim_front(str, param);
}

inline OMNI_STRING_T_FW trim_front(OMNI_STRING_T_FW str, OMNI_STRING_T_FW params)
{
    return omni::string::util::trim_front(str, params);
}

inline OMNI_STRING_T_FW trim_front(OMNI_STRING_T_FW str, OMNI_SEQ_T<OMNI_CHAR_T_FW>& params)
{
    return omni::string::util::trim_front(str, params.begin(), params.end());
}

template < std::size_t X >
inline OMNI_STRING_T_FW trim_front(OMNI_STRING_T_FW str, const OMNI_CHAR_T_FW (&params)[X])
{
    return omni::string::util::trim_front(str, OMNI_STRING_T_FW(params));
}

inline OMNI_STRING_T_FW trim_syschars(OMNI_STRING_T_FW str)
{
    return omni::string::util::trim_syschars(str);
}

inline OMNI_STRING_T_FW trim_front_syschars(OMNI_STRING_T_FW str)
{
    return omni::string::util::trim_front_syschars(str);
}

inline OMNI_STRING_T_FW trim_end_syschars(OMNI_STRING_T_FW str)
{
    return omni::string::util::trim_end_syschars(str);
}

template < typename T >
inline OMNI_STRING_T_FW lexical_cast(const T& val)
{
    return omni::string::util::lexical_cast<OMNI_STRING_T_FW>(val);
}

template < typename ret_t >
inline ret_t type_cast(const OMNI_STRING_T_FW& str)
{
    return omni::string::util::to_type<ret_t>(str);
}

template < typename ret_t >
inline ret_t type_cast(const OMNI_CHAR_T_FW* str)
{
    return omni::string::util::to_type<ret_t>(str);
}

template < typename ret_t, std::size_t X >
inline ret_t type_cast(const OMNI_CHAR_T_FW (&str)[X])
{
    return omni::string::util::to_type<ret_t>(OMNI_STRING_T_FW(str));
}

// } namespace omni::string/cstring/wstring