added: to convert/text

wchar_t ToLower(wchar_t c)
       wchar_t ToUpper(wchar_t c)
       void ToLower(std::wstring & s)
       void ToUpper(std::wstring & s)
       
       template<class StringType1, class StringType2>
       bool EqualNoCase(const StringType1 * str1, const StringType2 * str2)

       template<class StringType1, class StringType2>
       bool EqualNoCase(const StringType1 & str1, const StringType2 & str2)

       template<class StringType1, class StringType2>
       bool EqualNoCase(const StringType1 * str1_begin, const StringType1 * str1_end, const StringType2 * str2)

added: to space:
       Value * GetValueNoCase(const wchar_t * name);
       Value * GetValueNoCase(const std::wstring & name);
       const Value * GetValueNoCase(const wchar_t * name) const;
       const Value * GetValueNoCase(const std::wstring & name) const;

       
       



git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@1111 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2018-05-25 17:12:28 +00:00
parent 72a510ce71
commit 040eb12c8b
4 changed files with 152 additions and 60 deletions

View File

@@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2017, Tomasz Sowa
* Copyright (c) 2017-2018, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -153,6 +153,43 @@ bool IsDigit(wchar_t c, int base, int * digit)
wchar_t ToLower(wchar_t c)
{
if( c >= 'A' && c <= 'Z' )
return c - 'A' + 'a';
return c;
}
wchar_t ToUpper(wchar_t c)
{
if( c >= 'a' && c <= 'z' )
return c - 'a' + 'A';
return c;
}
void ToLower(std::wstring & s)
{
std::wstring::size_type i;
for(i=0 ; i<s.size() ; ++i)
s[i] = ToLower(s[i]);
}
void ToUpper(std::wstring & s)
{
std::wstring::size_type i;
for(i=0 ; i<s.size() ; ++i)
s[i] = ToUpper(s[i]);
}
}

View File

@@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2017, Tomasz Sowa
* Copyright (c) 2017-2018, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -38,6 +38,8 @@
#ifndef headerfile_picotools_convert_text
#define headerfile_picotools_convert_text
#include <string>
namespace PT
@@ -95,6 +97,57 @@ CharType * SkipWhiteFromBack(CharType * str, bool check_additional_chars = true,
}
wchar_t ToLower(wchar_t c);
wchar_t ToUpper(wchar_t c);
// change to a template
void ToLower(std::wstring & s);
void ToUpper(std::wstring & s);
template<class StringType1, class StringType2>
bool EqualNoCase(const StringType1 * str1, const StringType2 * str2)
{
while( *str1 && *str2 && ToLower(*str1) == ToLower(*str2) )
{
++str1;
++str2;
}
if( *str1 == 0 && *str2 == 0 )
return true;
return false;
}
template<class StringType1, class StringType2>
bool EqualNoCase(const StringType1 & str1, const StringType2 & str2)
{
return EqualNoCase(str1.c_str(), str2.c_str());
}
template<class StringType1, class StringType2>
bool EqualNoCase(const StringType1 * str1_begin, const StringType1 * str1_end, const StringType2 * str2)
{
while( str1_begin < str1_end && *str2 && PT::ToLower(*str1_begin) == PT::ToLower(*str2) )
{
++str1_begin;
++str2;
}
if( str1_begin == str1_end && *str2 == 0 )
return true;
return false;
}
}