ITK  6.0.0
Insight Toolkit
itkStringTools.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0.txt
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *=========================================================================*/
18
19#ifndef itkStringTools_h
20#define itkStringTools_h
21
22#include <vector>
23#include <map>
24#include "itkArray.h"
25#include "ITKIOXMLExport.h"
26
27namespace itk
28{
29
39class ITKIOXML_EXPORT StringTools
40{
41public:
43 // helper functions for converting a string to/from a std::vector
45
55 template <typename T>
56 static std::string &
57 ToData(std::string & s, std::vector<T> & data, int count = -1);
64 template <typename T>
65 static std::string &
66 FromData(std::string & s, const std::vector<T> & data);
67
69 // helper functions for converting a string to/from a itk::Array
71
81 template <typename T>
82 static std::string &
83 ToData(std::string & s, Array<T> & data, int count = -1);
90 template <typename T>
91 static std::string &
92 FromData(std::string & s, const Array<T> & data);
93
95 // helper functions for converting a string to/from a basic data type
97
102 template <typename T>
103 static std::string &
104 ToData(std::string & s, T & data);
105
110 template <typename T>
111 static std::string &
112 FromData(std::string & s, const T & data);
113
115 // helper functions for string manipulations
117
119 static std::string &
120 Trim(std::string & str, const std::string & dislike = " \t\n\r");
121
123 static std::string &
124 TrimLeft(std::string & str, const std::string & dislike = " \t\n\r");
125
127 static std::string &
128 TrimRight(std::string & str, const std::string & dislike = " \t\n\r");
129
131 static std::string &
132 ToUpperCase(std::string & str);
133
135 static std::string &
136 ToLowerCase(std::string & str);
137
139 static void
140 Split(const std::string & s, std::string & lpart, std::string & rpart, const std::string & delims = "=:");
141
143 static void
144 Split(const std::string & s, std::vector<std::string> & result, const std::string & delims = ";|");
145
150 static void
151 Split(const std::string & s, std::map<std::string, std::string> & result, const std::string & delims = ";|");
152
154 static bool
155 MatchWith(const std::string & s1, const std::string & s2, bool ignoreCase = true);
156
158 static bool
159 StartWith(const std::string & s1, const std::string & s2, bool ignoreCase = true);
160
162 static bool
163 EndWith(const std::string & s1, const std::string & s2, bool ignoreCase = true);
164
166 static bool
167 ContainSub(const std::string & s1, const std::string & s2, bool ignoreCase = true);
168}; // class StringTools
169
170} // namespace itk
171
172#ifndef ITK_MANUAL_INSTANTIATION
173# include "itkStringTools.hxx"
174#endif
175
176#endif // itkStringTools_h
Array class with size defined at construction time.
Definition: itkArray.h:48
A set of tools to manipulate a string.
static void Split(const std::string &s, std::map< std::string, std::string > &result, const std::string &delims=";|")
static std::string & ToLowerCase(std::string &str)
static bool StartWith(const std::string &s1, const std::string &s2, bool ignoreCase=true)
static bool ContainSub(const std::string &s1, const std::string &s2, bool ignoreCase=true)
static std::string & FromData(std::string &s, const std::vector< T > &data)
static std::string & ToData(std::string &s, Array< T > &data, int count=-1)
static std::string & ToData(std::string &s, T &data)
static std::string & ToUpperCase(std::string &str)
static void Split(const std::string &s, std::vector< std::string > &result, const std::string &delims=";|")
static bool MatchWith(const std::string &s1, const std::string &s2, bool ignoreCase=true)
static std::string & TrimRight(std::string &str, const std::string &dislike=" \t\n\r")
static void Split(const std::string &s, std::string &lpart, std::string &rpart, const std::string &delims="=:")
static std::string & ToData(std::string &s, std::vector< T > &data, int count=-1)
static std::string & FromData(std::string &s, const Array< T > &data)
static std::string & Trim(std::string &str, const std::string &dislike=" \t\n\r")
static bool EndWith(const std::string &s1, const std::string &s2, bool ignoreCase=true)
static std::string & TrimLeft(std::string &str, const std::string &dislike=" \t\n\r")
static std::string & FromData(std::string &s, const T &data)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....