OpenASIP  2.0
StringTools.hh
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2019 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25  * @file StringTools.hh
26  *
27  * Helper functions for handling strings.
28  *
29  * @deprecated New helpers should be added to TCEString instead.
30  *
31  * Declarations.
32  *
33  * @author Pekka Jääskeläinen 2004 (pjaaskel-no.spam-cs.tut.fi)
34  * @note rating: red
35  */
36 
37 #ifndef TTA_STRINGTOOLS_HH
38 #define TTA_STRINGTOOLS_HH
39 
40 #include <string>
41 #include <vector>
42 #include "TCEString.hh"
43 
44 class StringTools {
45 
46 public:
47  static std::string trim(const std::string& source);
48  static char* stringToCharPtr(const std::string& source);
49 
50  static bool containsChar(
51  const std::string& source,
52  char ch,
53  bool caseSensitive = true);
54 
55  static bool endsWith(
56  const std::string& source,
57  const std::string& searchString);
58 
59  static std::string stringToUpper(const std::string& source);
60  static std::string stringToLower(const std::string& source);
61  static bool ciEqual(const std::string& a, const std::string& b);
62 
63  static std::vector<TCEString> chopString(
64  const std::string& source,
65  const std::string& delimiters);
66 
67  static void chopString(
68  const std::string& source,
69  const std::string& delimiter,
70  std::vector<std::string>& results);
71 
72  static std::string splitToRows(
73  const std::string& original,
74  const unsigned int rowLength);
75 
76  static std::string replaceAllOccurrences(
77  const std::string& source,
78  const std::string& occurrence,
79  const std::string& newString);
80 
81  static std::string indent(int level);
82 };
83 
84 #endif
StringTools::endsWith
static bool endsWith(const std::string &source, const std::string &searchString)
Definition: StringTools.cc:126
StringTools::containsChar
static bool containsChar(const std::string &source, char ch, bool caseSensitive=true)
Definition: StringTools.cc:101
StringTools::stringToCharPtr
static char * stringToCharPtr(const std::string &source)
Definition: StringTools.cc:83
StringTools::indent
static std::string indent(int level)
Definition: StringTools.cc:319
StringTools::replaceAllOccurrences
static std::string replaceAllOccurrences(const std::string &source, const std::string &occurrence, const std::string &newString)
Definition: StringTools.cc:295
TCEString.hh
StringTools::stringToUpper
static std::string stringToUpper(const std::string &source)
Definition: StringTools.cc:143
StringTools
Definition: StringTools.hh:44
StringTools::ciEqual
static bool ciEqual(const std::string &a, const std::string &b)
Definition: StringTools.cc:240
StringTools::trim
static std::string trim(const std::string &source)
Definition: StringTools.cc:55
StringTools::chopString
static std::vector< TCEString > chopString(const std::string &source, const std::string &delimiters)
Definition: StringTools.cc:181
StringTools::stringToLower
static std::string stringToLower(const std::string &source)
Definition: StringTools.cc:160
StringTools::splitToRows
static std::string splitToRows(const std::string &original, const unsigned int rowLength)
Definition: StringTools.cc:262