ContRap-Core
|
This file contains common string operations. More...
#include <vector>
#include <string>
#include <sstream>
#include "core/coreexports.h"
#include "core/systemtools.h"
Namespaces | |
namespace | crp |
The namespace crp is the namespace for all ContRap core components and libraries. | |
Functions | |
CONTRAP_CORE_API std::string | crp::trim (const std::string &string) |
Converts a string not to have leading, tail or subsequent. | |
CONTRAP_CORE_API std::string | crp::trimlr (const std::string &string) |
Converts a string not to have leading or tail subsequent. | |
CONTRAP_CORE_API std::string | crp::up (const std::string &string) |
Converts a string to upper case. | |
CONTRAP_CORE_API std::string | crp::low (const std::string &string) |
Converts a string to lower case. | |
CONTRAP_CORE_API std::string | crp::b2s (const bool value) |
Converts an boolean to a string. | |
CONTRAP_CORE_API std::string | crp::p2s (const void *pointer) |
Converts an pointer to a string. | |
CONTRAP_CORE_API std::string | crp::i2s (integer_t value) |
Converts an integer to a string. | |
CONTRAP_CORE_API std::string | crp::d2s (floating_t value, size_t decimal=0) |
Converts a double to a string. | |
CONTRAP_CORE_API floating_t | crp::s2d (const std::string &value) |
Converts a string to a double. | |
CONTRAP_CORE_API integer_t | crp::s2i (const std::string &value) |
Converts a string to an int. | |
CONTRAP_CORE_API integer_t | crp::s2ih (const std::string &value) |
Converts a string in hexadecimal representation to an int. | |
CONTRAP_CORE_API bool | crp::is_number (const std::string &value) |
Checks if the string is a number. | |
CONTRAP_CORE_API bool | crp::is_float (const std::string &value) |
Checks if the string is a floating point number. | |
CONTRAP_CORE_API bool | crp::is_hex (const std::string &value) |
Checks if the string is a hexdecimal number. | |
CONTRAP_CORE_API bool | crp::starts_with (const std::string &string, const std::string &start) |
Checks if a string starts with a certain phrase. | |
CONTRAP_CORE_API bool | crp::matches (const std::string &text, size_t position, const std::string &phrase) |
Checks if a string matches with a certain phrase a the given position. | |
CONTRAP_CORE_API bool | crp::ends_with (const std::string &string, const std::string &end) |
Checks if a string ends with a certain phrase. | |
CONTRAP_CORE_API std::string | crp::underscore_string (const std::string &input) |
Creates a new string from an input string, where each non-letter or number is replaced by "_". | |
CONTRAP_CORE_API std::string | crp::remove_comments (const std::string &string) |
Throws away all characters after a hash symbol. | |
CONTRAP_CORE_API std::string | crp::remove_invisible_symbols (const std::string &input) |
Removes all invisible and non ASCII symbols. | |
CONTRAP_CORE_API std::string | crp::insert_line_breaks (const std::string &input, int length) |
Inserts new lines into a string to ensure the text the given length in each line. | |
CONTRAP_CORE_API std::string | crp::escape_symbol (const std::string &string, char symbol, const std::string &escape) |
Escapes each occurrence of the given symbol. | |
CONTRAP_CORE_API std::string | crp::replace (const std::string &string, const std::string &query, const std::string &replace) |
Replaces a single query. | |
CONTRAP_CORE_API std::string | crp::multiple_replace (const std::string &string, const std::vector< std::string > &queries, const std::vector< std::string > &replace) |
Replaces a multiple set of queries one after another. | |
CONTRAP_CORE_API std::string | crp::trim_size (const std::string &input, int length) |
Trims a string to the given length by removing inner symbols and inserting a ... | |
CONTRAP_CORE_API std::vector < std::string > | crp::break_string (const std::string &input) |
Creates an array of strings separated by the exactly the selector ':' excluding ':=' and '::'. | |
CONTRAP_CORE_API std::vector < double > | crp::break_string (const std::string &input, const std::string &delimiters) |
Creates a double array from a string with given separators. | |
CONTRAP_CORE_API std::vector < std::string > | crp::break_strings (const std::string &input, const std::string &delimiters) |
Creates an array of strings separated by the given delimiter. | |
CONTRAP_CORE_API bool | crp::string_to_range (const std::string &input, double &min, double &max, const std::string &delimiter="..") |
Interprets a string as a range separated by a given delimiter symbol ('..' by default) | |
CONTRAP_CORE_API std::vector < std::string > | crp::get_cpp_error (const std::string &input) |
Finds compiler error messages for the GNU C++ compiler. | |
CONTRAP_CORE_API std::string | crp::replace_tokens (const std::string &input, const std::string &query, const std::string &replacement, const std::string &delimiters) |
Replaces in a given string occurrences of a query string, which are tokens with respect to a given set of delimiters. | |
CONTRAP_CORE_API std::string | crp::to_rich_text (const std::string &text) |
Prepares the string for meta-ritch text output. | |
CONTRAP_CORE_API std::string | crp::to_cpp_text (const std::string &text) |
Prepares a string for printing to a C++ file. | |
CONTRAP_CORE_API size_t | crp::find_delimiter (const std::string &text) |
Returns the position of a single ":" from the beginning in the string or std::string::npos. | |
CONTRAP_CORE_API int | crp::count_occurrences (const std::string &text, const std::string &query) |
Counts the number of occurrences of a substring in the string. |
This file contains common string operations.
This file is a part of ContRap.
Copyright (c) 2009-2010 by Aless Lasaruk. 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 of ContRap nor the names of its contributors 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 HOLDER 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.