added: functions for dealing with white characters:
bool IsWhite(wchar_t c, bool check_additional_chars, bool treat_new_line_as_white) (checking unicode white characters too)
CharType * SkipWhite(CharType * str, bool check_additional_chars = true, bool treat_new_line_as_white = true)
IsDigit(wchar_t c, int base, int * digit)
added: functions to converting from a string to an integer:
unsigned long long Toull(const CharType * str, int base = 10, const CharType ** after_str = 0, bool * was_overflow = 0)
long long Toll(const CharType * str, int base = 10, const CharType ** after_str = 0, bool * was_overflow = 0)
unsigned long Toul(const CharType * str, int base = 10, const CharType ** after_str = 0, bool * was_overflow = 0)
unsigned int Toui(const CharType * str, int base = 10, const CharType ** after_str = 0, bool * was_overflow = 0)
long Tol(const CharType * str, int base = 10, const CharType ** after_str = 0, bool * was_overflow = 0)
int Toi(const CharType * str, int base = 10, const CharType ** after_str = 0, bool * was_overflow = 0)
changed: some work in Space (new Api)
now Text() methods returns std::wstring by value (before they were returned by reference)
added std::wstring & TextRef() methods
added unsigned int UInt(), unsigned long ULong() and LongLong() and ULongLong()
GetValue() renamed to GetFirstValue()
AText() renamed to TextA() and they return std::string by value now
git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@1066 e52654a7-88a9-db11-a3e9-0013d4bc506e
2017-12-05 17:32:21 +01:00
|
|
|
/*
|
|
|
|
* This file is a part of PikoTools
|
|
|
|
* and is distributed under the (new) BSD licence.
|
|
|
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2021-05-08 22:37:31 +02:00
|
|
|
* Copyright (c) 2017-2021, Tomasz Sowa
|
added: functions for dealing with white characters:
bool IsWhite(wchar_t c, bool check_additional_chars, bool treat_new_line_as_white) (checking unicode white characters too)
CharType * SkipWhite(CharType * str, bool check_additional_chars = true, bool treat_new_line_as_white = true)
IsDigit(wchar_t c, int base, int * digit)
added: functions to converting from a string to an integer:
unsigned long long Toull(const CharType * str, int base = 10, const CharType ** after_str = 0, bool * was_overflow = 0)
long long Toll(const CharType * str, int base = 10, const CharType ** after_str = 0, bool * was_overflow = 0)
unsigned long Toul(const CharType * str, int base = 10, const CharType ** after_str = 0, bool * was_overflow = 0)
unsigned int Toui(const CharType * str, int base = 10, const CharType ** after_str = 0, bool * was_overflow = 0)
long Tol(const CharType * str, int base = 10, const CharType ** after_str = 0, bool * was_overflow = 0)
int Toi(const CharType * str, int base = 10, const CharType ** after_str = 0, bool * was_overflow = 0)
changed: some work in Space (new Api)
now Text() methods returns std::wstring by value (before they were returned by reference)
added std::wstring & TextRef() methods
added unsigned int UInt(), unsigned long ULong() and LongLong() and ULongLong()
GetValue() renamed to GetFirstValue()
AText() renamed to TextA() and they return std::string by value now
git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@1066 e52654a7-88a9-db11-a3e9-0013d4bc506e
2017-12-05 17:32:21 +01:00
|
|
|
* 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 Tomasz Sowa nor the names of contributors to this
|
|
|
|
* project may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 THE COPYRIGHT OWNER OR 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef headerfile_picotools_convert_text
|
|
|
|
#define headerfile_picotools_convert_text
|
|
|
|
|
2021-05-10 20:04:12 +02:00
|
|
|
#include <string>
|
added: functions for dealing with white characters:
bool IsWhite(wchar_t c, bool check_additional_chars, bool treat_new_line_as_white) (checking unicode white characters too)
CharType * SkipWhite(CharType * str, bool check_additional_chars = true, bool treat_new_line_as_white = true)
IsDigit(wchar_t c, int base, int * digit)
added: functions to converting from a string to an integer:
unsigned long long Toull(const CharType * str, int base = 10, const CharType ** after_str = 0, bool * was_overflow = 0)
long long Toll(const CharType * str, int base = 10, const CharType ** after_str = 0, bool * was_overflow = 0)
unsigned long Toul(const CharType * str, int base = 10, const CharType ** after_str = 0, bool * was_overflow = 0)
unsigned int Toui(const CharType * str, int base = 10, const CharType ** after_str = 0, bool * was_overflow = 0)
long Tol(const CharType * str, int base = 10, const CharType ** after_str = 0, bool * was_overflow = 0)
int Toi(const CharType * str, int base = 10, const CharType ** after_str = 0, bool * was_overflow = 0)
changed: some work in Space (new Api)
now Text() methods returns std::wstring by value (before they were returned by reference)
added std::wstring & TextRef() methods
added unsigned int UInt(), unsigned long ULong() and LongLong() and ULongLong()
GetValue() renamed to GetFirstValue()
AText() renamed to TextA() and they return std::string by value now
git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@1066 e52654a7-88a9-db11-a3e9-0013d4bc506e
2017-12-05 17:32:21 +01:00
|
|
|
|
|
|
|
|
2021-05-20 16:11:12 +02:00
|
|
|
namespace pt
|
added: functions for dealing with white characters:
bool IsWhite(wchar_t c, bool check_additional_chars, bool treat_new_line_as_white) (checking unicode white characters too)
CharType * SkipWhite(CharType * str, bool check_additional_chars = true, bool treat_new_line_as_white = true)
IsDigit(wchar_t c, int base, int * digit)
added: functions to converting from a string to an integer:
unsigned long long Toull(const CharType * str, int base = 10, const CharType ** after_str = 0, bool * was_overflow = 0)
long long Toll(const CharType * str, int base = 10, const CharType ** after_str = 0, bool * was_overflow = 0)
unsigned long Toul(const CharType * str, int base = 10, const CharType ** after_str = 0, bool * was_overflow = 0)
unsigned int Toui(const CharType * str, int base = 10, const CharType ** after_str = 0, bool * was_overflow = 0)
long Tol(const CharType * str, int base = 10, const CharType ** after_str = 0, bool * was_overflow = 0)
int Toi(const CharType * str, int base = 10, const CharType ** after_str = 0, bool * was_overflow = 0)
changed: some work in Space (new Api)
now Text() methods returns std::wstring by value (before they were returned by reference)
added std::wstring & TextRef() methods
added unsigned int UInt(), unsigned long ULong() and LongLong() and ULongLong()
GetValue() renamed to GetFirstValue()
AText() renamed to TextA() and they return std::string by value now
git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@1066 e52654a7-88a9-db11-a3e9-0013d4bc506e
2017-12-05 17:32:21 +01:00
|
|
|
{
|
|
|
|
|
2021-05-10 20:04:12 +02:00
|
|
|
bool is_white(wchar_t c, bool check_additional_chars = true, bool treat_new_line_as_white = true);
|
|
|
|
bool is_digit(wchar_t c, int base = 10, int * digit = 0);
|
2021-05-08 22:37:31 +02:00
|
|
|
|
2021-05-10 20:04:12 +02:00
|
|
|
const char * skip_white(const char * str, bool check_additional_chars = true, bool treat_new_line_as_white = true);
|
|
|
|
const wchar_t * skip_white(const wchar_t * str, bool check_additional_chars = true, bool treat_new_line_as_white = true);
|
2021-05-08 22:37:31 +02:00
|
|
|
|
added: functions for dealing with white characters:
bool IsWhite(wchar_t c, bool check_additional_chars, bool treat_new_line_as_white) (checking unicode white characters too)
CharType * SkipWhite(CharType * str, bool check_additional_chars = true, bool treat_new_line_as_white = true)
IsDigit(wchar_t c, int base, int * digit)
added: functions to converting from a string to an integer:
unsigned long long Toull(const CharType * str, int base = 10, const CharType ** after_str = 0, bool * was_overflow = 0)
long long Toll(const CharType * str, int base = 10, const CharType ** after_str = 0, bool * was_overflow = 0)
unsigned long Toul(const CharType * str, int base = 10, const CharType ** after_str = 0, bool * was_overflow = 0)
unsigned int Toui(const CharType * str, int base = 10, const CharType ** after_str = 0, bool * was_overflow = 0)
long Tol(const CharType * str, int base = 10, const CharType ** after_str = 0, bool * was_overflow = 0)
int Toi(const CharType * str, int base = 10, const CharType ** after_str = 0, bool * was_overflow = 0)
changed: some work in Space (new Api)
now Text() methods returns std::wstring by value (before they were returned by reference)
added std::wstring & TextRef() methods
added unsigned int UInt(), unsigned long ULong() and LongLong() and ULongLong()
GetValue() renamed to GetFirstValue()
AText() renamed to TextA() and they return std::string by value now
git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@1066 e52654a7-88a9-db11-a3e9-0013d4bc506e
2017-12-05 17:32:21 +01:00
|
|
|
|
|
|
|
|
added: to methods Toull(), Toll(), Toul(), Toui(), Tol(), Toi()
a new parameter: bool allow_skip_whitechars default true
added: new methods: Toull_b(), Toll_b(), Toul_b(), Toui_b(), Tol_b(), Toi_b()
automatically detects the base (radix):
4323 - base 10
0122 - base 8 (string starts with 0)
#fff - base 16 (string starts with #)
&101 - base 2 (string starts with &)
added: CharType * SkipWhiteFromBack(CharType * str, bool check_additional_chars = true, bool treat_new_line_as_white = true)
skipping white characters from the end of a string
changed: Toll_b(), Toull_b(), Tol_b() and Toul_b() are used in Space now
for methods ToInt() etc so we are able to use a different base now
changed: some work in Space (const correctness)
git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@1070 e52654a7-88a9-db11-a3e9-0013d4bc506e
2018-01-05 21:03:11 +01:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* str_end is pointing at the end of the string (the last item + one)
|
|
|
|
*
|
|
|
|
* return value is a pointer to the first white character after a non-white character at the end
|
|
|
|
* or to the last+one if there is no any white characters
|
|
|
|
*
|
|
|
|
*/
|
2021-05-10 20:04:12 +02:00
|
|
|
const char * skip_white_from_back(const char * str_begin, const char * str_end, bool check_additional_chars = true, bool treat_new_line_as_white = true);
|
|
|
|
const wchar_t * skip_white_from_back(const wchar_t * str_begin, const wchar_t * str_end, bool check_additional_chars = true, bool treat_new_line_as_white = true);
|
2018-10-04 15:41:07 +02:00
|
|
|
|
2021-05-10 20:04:12 +02:00
|
|
|
const char * skip_white_from_back(const char * str, bool check_additional_chars = true, bool treat_new_line_as_white = true);
|
|
|
|
const wchar_t * skip_white_from_back(const wchar_t * str, bool check_additional_chars = true, bool treat_new_line_as_white = true);
|
2018-05-25 19:12:28 +02:00
|
|
|
|
2018-10-24 18:25:47 +02:00
|
|
|
|
|
|
|
|
2021-05-10 20:04:12 +02:00
|
|
|
char to_lower(char c);
|
|
|
|
wchar_t to_lower(wchar_t c);
|
2018-08-11 19:37:35 +02:00
|
|
|
|
2021-05-10 20:04:12 +02:00
|
|
|
char to_upper(char c);
|
|
|
|
wchar_t to_upper(wchar_t c);
|
2018-10-24 18:25:47 +02:00
|
|
|
|
2021-05-10 20:04:12 +02:00
|
|
|
void to_lower_emplace(std::string & str);
|
|
|
|
void to_lower_emplace(std::wstring & str);
|
2018-10-24 18:25:47 +02:00
|
|
|
|
2021-05-10 20:04:12 +02:00
|
|
|
void to_upper_emplace(std::string & str);
|
|
|
|
void to_upper_emplace(std::wstring & str);
|
2018-10-24 18:25:47 +02:00
|
|
|
|
2021-05-10 20:04:12 +02:00
|
|
|
std::string to_lower(const std::string & str);
|
|
|
|
std::wstring to_lower(const std::wstring & str);
|
2018-10-04 15:41:07 +02:00
|
|
|
|
2021-05-10 20:04:12 +02:00
|
|
|
std::string to_upper(const std::string & str);
|
|
|
|
std::wstring to_upper(const std::wstring & str);
|
2018-05-25 19:12:28 +02:00
|
|
|
|
|
|
|
|
2021-05-10 20:04:12 +02:00
|
|
|
int compare(const char * str1, const char * str2);
|
|
|
|
int compare(const wchar_t * str1, const wchar_t * str2);
|
2018-05-25 19:12:28 +02:00
|
|
|
|
2021-05-10 20:04:12 +02:00
|
|
|
int compare(const std::string & str1, const std::string & str2);
|
|
|
|
int compare(const std::wstring & str1, const std::wstring & str2);
|
2018-10-24 18:25:47 +02:00
|
|
|
|
2021-05-10 20:04:12 +02:00
|
|
|
int compare(const char * str1_begin, const char * str1_end, const char * str2);
|
|
|
|
int compare(const wchar_t * str1_begin, const wchar_t * str1_end, const wchar_t * str2);
|
2018-10-24 18:25:47 +02:00
|
|
|
|
2018-10-30 00:47:23 +01:00
|
|
|
|
2021-05-10 20:04:12 +02:00
|
|
|
/*
|
|
|
|
* compare no case
|
|
|
|
*/
|
|
|
|
int compare_nc(const char * str1, const char * str2);
|
|
|
|
int compare_nc(const wchar_t * str1, const wchar_t * str2);
|
2018-10-30 00:47:23 +01:00
|
|
|
|
2021-05-10 20:04:12 +02:00
|
|
|
int compare_nc(const std::string & str1, const std::string & str2);
|
|
|
|
int compare_nc(const std::wstring & str1, const std::wstring & str2);
|
2018-10-30 00:47:23 +01:00
|
|
|
|
2021-05-10 20:04:12 +02:00
|
|
|
int compare_nc(const char * str1_begin, const char * str1_end, const char * str2);
|
|
|
|
int compare_nc(const wchar_t * str1_begin, const wchar_t * str1_end, const wchar_t * str2);
|
2018-10-30 00:47:23 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2021-05-10 20:04:12 +02:00
|
|
|
bool is_equal(const char * str1, const char * str2);
|
|
|
|
bool is_equal(const wchar_t * str1, const wchar_t * str2);
|
2018-10-30 00:47:23 +01:00
|
|
|
|
2021-05-10 20:04:12 +02:00
|
|
|
bool is_equal(const std::string & str1, const std::string & str2);
|
|
|
|
bool is_equal(const std::wstring & str1, const std::wstring & str2);
|
2018-10-30 00:47:23 +01:00
|
|
|
|
2021-05-10 20:04:12 +02:00
|
|
|
bool is_equal(const char * str1_begin, const char * str1_end, const char * str2);
|
|
|
|
bool is_equal(const wchar_t * str1_begin, const wchar_t * str1_end, const wchar_t * str2);
|
2018-10-30 00:47:23 +01:00
|
|
|
|
2021-05-10 20:04:12 +02:00
|
|
|
bool is_equal_nc(const char * str1, const char * str2);
|
|
|
|
bool is_equal_nc(const wchar_t * str1, const wchar_t * str2);
|
2018-10-30 00:47:23 +01:00
|
|
|
|
2021-05-10 20:04:12 +02:00
|
|
|
bool is_equal_nc(const std::string & str1, const std::string & str2);
|
|
|
|
bool is_equal_nc(const std::wstring & str1, const std::wstring & str2);
|
2018-10-30 00:47:23 +01:00
|
|
|
|
2021-05-10 20:04:12 +02:00
|
|
|
bool is_equal_nc(const char * str1_begin, const char * str1_end, const char * str2);
|
|
|
|
bool is_equal_nc(const wchar_t * str1_begin, const wchar_t * str1_end, const wchar_t * str2);
|
2018-10-30 00:47:23 +01:00
|
|
|
|
|
|
|
|
2021-05-10 20:04:12 +02:00
|
|
|
bool is_substr(const char * short_str, const char * long_str);
|
|
|
|
bool is_substr(const wchar_t * short_str, const wchar_t * long_str);
|
2018-10-30 00:47:23 +01:00
|
|
|
|
2021-05-10 20:04:12 +02:00
|
|
|
bool is_substr(const std::string & short_str, const std::string & long_str);
|
|
|
|
bool is_substr(const std::wstring & short_str, const std::wstring & long_str);
|
2018-10-30 00:47:23 +01:00
|
|
|
|
2021-05-10 20:04:12 +02:00
|
|
|
bool is_substr_nc(const char * short_str, const char * long_str);
|
|
|
|
bool is_substr_nc(const wchar_t * short_str, const wchar_t * long_str);
|
2018-10-30 00:47:23 +01:00
|
|
|
|
2021-05-10 20:04:12 +02:00
|
|
|
bool is_substr_nc(const std::string & short_str, const std::string & long_str);
|
|
|
|
bool is_substr_nc(const std::wstring & short_str, const std::wstring & long_str);
|
2018-10-30 00:47:23 +01:00
|
|
|
|
|
|
|
|
added trim(...) functions to convert/text.h
void trim_first_white(std::string & str, bool check_additional_chars = true, bool treat_new_line_as_white = true);
void trim_first_white(std::wstring & str, bool check_additional_chars = true, bool treat_new_line_as_white = true);
void trim_last_white(std::string & str, bool check_additional_chars = true, bool treat_new_line_as_white = true);
void trim_last_white(std::wstring & str, bool check_additional_chars = true, bool treat_new_line_as_white = true);
void trim_white(std::string & str, bool check_additional_chars = true, bool treat_new_line_as_white = true);
void trim_white(std::wstring & str, bool check_additional_chars = true, bool treat_new_line_as_white = true);
void trim_first(std::string & str, wchar_t c);
void trim_first(std::wstring & str, wchar_t c);
void trim_last(std::string & str, wchar_t c);
void trim_last(std::wstring & str, wchar_t c);
void trim(std::string & str, wchar_t c);
void trim(std::wstring & str, wchar_t c);
2021-06-29 23:23:35 +02:00
|
|
|
void trim_first_white(std::string & str, bool check_additional_chars = true, bool treat_new_line_as_white = true);
|
|
|
|
void trim_first_white(std::wstring & str, bool check_additional_chars = true, bool treat_new_line_as_white = true);
|
|
|
|
|
|
|
|
void trim_last_white(std::string & str, bool check_additional_chars = true, bool treat_new_line_as_white = true);
|
|
|
|
void trim_last_white(std::wstring & str, bool check_additional_chars = true, bool treat_new_line_as_white = true);
|
|
|
|
|
|
|
|
void trim_white(std::string & str, bool check_additional_chars = true, bool treat_new_line_as_white = true);
|
|
|
|
void trim_white(std::wstring & str, bool check_additional_chars = true, bool treat_new_line_as_white = true);
|
|
|
|
|
|
|
|
void trim_first(std::string & str, wchar_t c);
|
|
|
|
void trim_first(std::wstring & str, wchar_t c);
|
|
|
|
|
|
|
|
void trim_last(std::string & str, wchar_t c);
|
|
|
|
void trim_last(std::wstring & str, wchar_t c);
|
|
|
|
|
|
|
|
void trim(std::string & str, wchar_t c);
|
|
|
|
void trim(std::wstring & str, wchar_t c);
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-10-30 00:47:23 +01:00
|
|
|
|
added: functions for dealing with white characters:
bool IsWhite(wchar_t c, bool check_additional_chars, bool treat_new_line_as_white) (checking unicode white characters too)
CharType * SkipWhite(CharType * str, bool check_additional_chars = true, bool treat_new_line_as_white = true)
IsDigit(wchar_t c, int base, int * digit)
added: functions to converting from a string to an integer:
unsigned long long Toull(const CharType * str, int base = 10, const CharType ** after_str = 0, bool * was_overflow = 0)
long long Toll(const CharType * str, int base = 10, const CharType ** after_str = 0, bool * was_overflow = 0)
unsigned long Toul(const CharType * str, int base = 10, const CharType ** after_str = 0, bool * was_overflow = 0)
unsigned int Toui(const CharType * str, int base = 10, const CharType ** after_str = 0, bool * was_overflow = 0)
long Tol(const CharType * str, int base = 10, const CharType ** after_str = 0, bool * was_overflow = 0)
int Toi(const CharType * str, int base = 10, const CharType ** after_str = 0, bool * was_overflow = 0)
changed: some work in Space (new Api)
now Text() methods returns std::wstring by value (before they were returned by reference)
added std::wstring & TextRef() methods
added unsigned int UInt(), unsigned long ULong() and LongLong() and ULongLong()
GetValue() renamed to GetFirstValue()
AText() renamed to TextA() and they return std::string by value now
git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@1066 e52654a7-88a9-db11-a3e9-0013d4bc506e
2017-12-05 17:32:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|