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
This commit is contained in:
2018-01-05 20:03:11 +00:00
parent e24112b79b
commit cb23304885
4 changed files with 325 additions and 130 deletions

View File

@@ -206,7 +206,12 @@ public:
*
*/
// moze tu powinno być FindValue?
/*
*
* their working in O(log)
* can return a null pointer
*
*/
Value * GetValue(const wchar_t * name);
Value * GetValue(const std::wstring & name);
@@ -214,7 +219,6 @@ public:
const Value * GetValue(const std::wstring & name) const;
// moze tu powinno być FindFirstValue?
// they can return a null pointer if there is not such a 'name'
std::wstring * GetFirstValue(const wchar_t * name);
std::wstring * GetFirstValue(const std::wstring & name);
@@ -260,26 +264,26 @@ public:
int Int(const wchar_t * name, int def = 0);
int Int(const std::wstring & name, int def = 0);
unsigned int UInt(const wchar_t * name, unsigned int def = 0);
unsigned int UInt(const std::wstring & name, unsigned int def = 0);
int Int(const wchar_t * name, int def = 0) const;
int Int(const std::wstring & name, int def = 0) const;
unsigned int UInt(const wchar_t * name, unsigned int def = 0) const;
unsigned int UInt(const std::wstring & name, unsigned int def = 0) const;
long Long(const wchar_t * name, long def = 0);
long Long(const std::wstring & name, long def = 0);
unsigned long ULong(const wchar_t * name, unsigned long def = 0);
unsigned long ULong(const std::wstring & name, unsigned long def = 0);
long Long(const wchar_t * name, long def = 0) const;
long Long(const std::wstring & name, long def = 0) const;
unsigned long ULong(const wchar_t * name, unsigned long def = 0) const;
unsigned long ULong(const std::wstring & name, unsigned long def = 0) const;
long long LongLong(const wchar_t * name, long long def = 0);
long long LongLong(const std::wstring & name, long long def = 0);
unsigned long long ULongLong(const wchar_t * name, unsigned long long def = 0);
unsigned long long ULongLong(const std::wstring & name, unsigned long long def = 0);
long long LongLong(const wchar_t * name, long long def = 0) const;
long long LongLong(const std::wstring & name, long long def = 0) const;
unsigned long long ULongLong(const wchar_t * name, unsigned long long def = 0) const;
unsigned long long ULongLong(const std::wstring & name, unsigned long long def = 0) const;
size_t Size(const wchar_t * name, size_t def = 0);
size_t Size(const std::wstring & name, size_t def = 0);
size_t Size(const wchar_t * name, size_t def = 0) const;
size_t Size(const std::wstring & name, size_t def = 0) const;
bool Bool(const wchar_t * name, bool def = false);
bool Bool(const std::wstring & name, bool def = false);
bool Bool(const wchar_t * name, bool def = false) const;
bool Bool(const std::wstring & name, bool def = false) const;
@@ -393,21 +397,20 @@ private:
std::wstring tmp_value_text;
std::string tmp_value_text_ascii;
int CheckIntegerBase(const std::wstring & value, const wchar_t ** save_ptr);
static unsigned int ToUInt(const std::wstring & value);
static int ToInt(const std::wstring & value);
static unsigned long ToULong(const std::wstring & value);
static long ToLong(const std::wstring & value);
static unsigned long long ToULongLong(const std::wstring & value);
static long long ToLongLong(const std::wstring & value);
static size_t ToSize(const std::wstring & value);
static bool ToBool(const std::wstring & value);
unsigned int ToUInt(const std::wstring & value);
int ToInt(const std::wstring & value);
unsigned long ToULong(const std::wstring & value);
long ToLong(const std::wstring & value);
unsigned long long ToULongLong(const std::wstring & value);
long long ToLongLong(const std::wstring & value);
size_t ToSize(const std::wstring & value);
bool ToBool(const std::wstring & value);
wchar_t ToSmall(wchar_t c);
bool EqualNoCase(const wchar_t * str1, const wchar_t * str2);
static bool IsWhite(int c);
static bool HasWhite(const std::wstring & str);
static wchar_t ToSmall(wchar_t c);
static bool EqualNoCase(const wchar_t * str1, const wchar_t * str2);
static bool EqualNoCase(const wchar_t * str1_begin, const wchar_t * str1_end, const wchar_t * str2);
static bool IsWhite(int c);
static bool HasWhite(const std::wstring & str);
};
@@ -459,6 +462,8 @@ void Space::PrintKey(Stream & out, const std::wstring & str)
{
bool use_quote = false;
// CHECK ME
// HasWhite doesn't take a new line into account, is it correct to use it here?
if( str.empty() || HasWhite(str) )
use_quote = true;