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
|
2022-06-30 12:09:22 +02:00
|
|
|
* and is distributed under the 2-Clause BSD licence.
|
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
|
|
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2022-07-26 05:14:35 +02:00
|
|
|
* Copyright (c) 2017-2022, 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:
|
|
|
|
*
|
2022-06-30 12:09:22 +02:00
|
|
|
* 1. Redistributions of source code must retain the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer.
|
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
|
|
|
*
|
2022-06-30 12:09:22 +02:00
|
|
|
* 2. 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.
|
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 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
|
2022-06-30 12:09:22 +02:00
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
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
|
|
|
* 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)
|
2022-06-30 12:09:22 +02:00
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
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
|
|
|
*/
|
|
|
|
|
2022-06-30 12:45:08 +02:00
|
|
|
#ifndef headerfile_pikotools_src_convert_text
|
|
|
|
#define headerfile_pikotools_src_convert_text
|
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
|
|
|
#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
|
|
|
|
2022-07-26 05:14:35 +02:00
|
|
|
|
|
|
|
// IMPROVEME add tests
|
|
|
|
template<typename HexStringPointerType, typename BytesStringType>
|
|
|
|
bool hex_string_pointer_to_bytes(const HexStringPointerType * hex_string, BytesStringType & bytes, bool clear_bytes = true)
|
|
|
|
{
|
|
|
|
bool converted_correctly = true;
|
|
|
|
size_t i = 0;
|
|
|
|
|
|
|
|
if( clear_bytes )
|
|
|
|
bytes.clear();
|
|
|
|
|
|
|
|
for( ; converted_correctly && hex_string[i] != 0 && hex_string[i+1] != 0 ; i += 2)
|
|
|
|
{
|
|
|
|
int c1, c2;
|
|
|
|
|
|
|
|
converted_correctly = converted_correctly && is_digit(hex_string[i], 16, &c1);
|
|
|
|
converted_correctly = converted_correctly && is_digit(hex_string[i+1], 16, &c2);
|
|
|
|
|
|
|
|
if( converted_correctly )
|
|
|
|
{
|
|
|
|
bytes += (char)(unsigned char)(((c1 << 4) | c2));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( hex_string[i] != 0 )
|
|
|
|
{
|
|
|
|
// one digit has left
|
|
|
|
converted_correctly = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return converted_correctly;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// IMPROVEME add tests
|
|
|
|
template<typename HexStringType, typename BytesStringType>
|
|
|
|
bool hex_string_to_bytes(const HexStringType & hex_string, BytesStringType & bytes, bool clear_bytes = true)
|
|
|
|
{
|
|
|
|
return hex_string_pointer_to_bytes(hex_string.c_str(), bytes, clear_bytes);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|