"Fossies" - the Fresh Open Source Software Archive

Member "highlight-3.57-x64/src/include/stringtools.h" (12 May 2020, 2822 Bytes) of package /windows/www/highlight-3.57-x64.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "stringtools.h": 3.55_vs_3.56.

    1 /***************************************************************************
    2                           stringtools.h  -  description
    3                              -------------------
    4     begin                : Mon Dec 10 2001
    5     copyright            : (C) 2001-2010 by Andre Simon
    6     email                : a.simon@mailbox.org
    7  ***************************************************************************/
    8 
    9 
   10 /*
   11 This file is part of Highlight.
   12 
   13 Highlight is free software: you can redistribute it and/or modify
   14 it under the terms of the GNU General Public License as published by
   15 the Free Software Foundation, either version 3 of the License, or
   16 (at your option) any later version.
   17 
   18 Highlight is distributed in the hope that it will be useful,
   19 but WITHOUT ANY WARRANTY; without even the implied warranty of
   20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   21 GNU General Public License for more details.
   22 
   23 You should have received a copy of the GNU General Public License
   24 along with Highlight.  If not, see <http://www.gnu.org/licenses/>.
   25 */
   26 
   27 
   28 #ifndef STRINGTOOLS_H
   29 #define STRINGTOOLS_H
   30 
   31 #include <string>
   32 #include <vector>
   33 #include <sstream>
   34 
   35 using namespace std;
   36 
   37 /// Contains methods for string manipulation
   38 
   39 namespace StringTools
   40 {
   41 
   42 /** Change Keyword case */
   43 enum KeywordCase {
   44     CASE_UNCHANGED, ///< do not alter case
   45     CASE_LOWER,     ///< convert to lower case
   46     CASE_UPPER,     ///< convert to upper case
   47     CASE_CAPITALIZE ///< convert first character to upper case
   48 };
   49 
   50 /** Change character case of strings
   51     \param s input string
   52     \param kcase case modification indicator
   53     \return modified string
   54 */
   55 string change_case ( const string & s,
   56                      const KeywordCase kcase = CASE_LOWER ) throw();
   57 
   58 /** Trim string (remove whitespace)
   59    \param value String
   60    \return string trimmed on the right
   61 */
   62 string trimRight ( const string &value );
   63 
   64 string trim(const string& s);
   65 
   66 /** Split string and return items separated by a delimiter
   67     \param s string containing tokens
   68     \param delim Token delimiter
   69     \return vector containing found tokens */
   70 vector <string> splitString ( const string& s, unsigned char delim );
   71 
   72 /** Convert string to a numeric value of the given type
   73     \param val variable of specified type which will contain the numeric value
   74     \param s string containing a number
   75     \param f format specifier function (IO manipulator)
   76     \return true if successful */
   77 template <class T>
   78 bool str2num ( T &val, const std::string& s, std::ios_base& ( *f ) ( std::ios_base& ) )
   79 {
   80     std::istringstream iss ( s );
   81     return ! ( iss >> f >> val ).fail();
   82 }
   83 
   84 int calcWeight(const string&s);
   85 
   86 string getPathAcronym(const string&path, char delim);
   87 
   88 bool endsWith(std::string const & value, std::string const & ending);
   89 
   90 int utf8_strlen(const string& str);
   91 }
   92 
   93 #endif