/* * This file is a part of PikoTools * and is distributed under the (new) BSD licence. * Author: Tomasz Sowa */ /* * Copyright (c) 2017-2021, Tomasz Sowa * 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 #include namespace PT { 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); 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); /* * * 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 * */ 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); 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); char to_lower(char c); wchar_t to_lower(wchar_t c); char to_upper(char c); wchar_t to_upper(wchar_t c); void to_lower_emplace(std::string & str); void to_lower_emplace(std::wstring & str); void to_upper_emplace(std::string & str); void to_upper_emplace(std::wstring & str); std::string to_lower(const std::string & str); std::wstring to_lower(const std::wstring & str); std::string to_upper(const std::string & str); std::wstring to_upper(const std::wstring & str); int compare(const char * str1, const char * str2); int compare(const wchar_t * str1, const wchar_t * str2); int compare(const std::string & str1, const std::string & str2); int compare(const std::wstring & str1, const std::wstring & str2); 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); /* * compare no case */ int compare_nc(const char * str1, const char * str2); int compare_nc(const wchar_t * str1, const wchar_t * str2); int compare_nc(const std::string & str1, const std::string & str2); int compare_nc(const std::wstring & str1, const std::wstring & str2); 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); bool is_equal(const char * str1, const char * str2); bool is_equal(const wchar_t * str1, const wchar_t * str2); bool is_equal(const std::string & str1, const std::string & str2); bool is_equal(const std::wstring & str1, const std::wstring & str2); 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); bool is_equal_nc(const char * str1, const char * str2); bool is_equal_nc(const wchar_t * str1, const wchar_t * str2); bool is_equal_nc(const std::string & str1, const std::string & str2); bool is_equal_nc(const std::wstring & str1, const std::wstring & str2); 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); bool is_substr(const char * short_str, const char * long_str); bool is_substr(const wchar_t * short_str, const wchar_t * long_str); 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); 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); 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); } #endif