ITK  6.0.0
Insight Toolkit
itkFancyString.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 itkFancyString_h
20#define itkFancyString_h
21
22#include <string>
23#include <vector>
24#include <map>
25#include "itkArray.h"
26#include "ITKIOXMLExport.h"
27
28namespace itk
29{
30
45class ITKIOXML_EXPORT FancyString
46{
47public:
49 FancyString(const std::string & str);
50 FancyString(const char * s);
54 operator=(const std::string & str);
56 operator=(const char * s);
57
59 operator const char *() const;
60
62 // helper functions for converting a string to/from a std::vector
64
74 template <typename T>
76 ToData(std::vector<T> & outputData, int count = -1);
83 template <typename T>
85 FromData(const std::vector<T> & inputData);
86
88 // helper functions for converting a string to/from a itk::Array
90
100 template <typename T>
102 ToData(Array<T> & outputData, int count = -1);
109 template <typename T>
111 FromData(const Array<T> & inputData);
112
114 // helper functions for converting a string to/from a basic data type
116
120 operator const std::string &() const;
121
125 const std::string &
126 ToString() const;
127
132 template <typename T>
134 ToData(T & outputData);
135
140 template <typename T>
142 FromData(const T & inputData);
143
145 // helper functions for string manipulations
147
149 void
151
153 void
154 Append(const FancyString & str);
155
158 Trim(const std::string & dislike = " \t\n\r");
159
162 TrimLeft(const std::string & dislike = " \t\n\r");
163
166 TrimRight(const std::string & dislike = " \t\n\r");
167
171
175
177 void
178 Split(std::string & lpart, std::string & rpart, const std::string & delims = "=:") const;
179
181 void
182 Split(std::vector<std::string> & result, const std::string & delims = ";|") const;
183
188 void
189 Split(std::map<std::string, std::string> & result, const std::string & delims = ";|");
190
192 bool
193 MatchWith(const std::string & s2, bool ignoreCase = true);
194
196 bool
197 StartWith(const std::string & s2, bool ignoreCase = true);
198
200 bool
201 EndWith(const std::string & s2, bool ignoreCase = true);
202
204 bool
205 ContainSub(const std::string & s2, bool ignoreCase = true);
206
207private:
208 std::string m_Value;
209
210}; // class FancyString
211
212} // namespace itk
213
215// helper function to compare FancyString with std::string and char*
217
218bool ITKIOXML_EXPORT
219 operator!=(itk::FancyString & s, const std::string &);
220bool ITKIOXML_EXPORT
221 operator!=(itk::FancyString & s, const char *);
222bool ITKIOXML_EXPORT
224
225bool ITKIOXML_EXPORT
226 operator==(itk::FancyString & s, const std::string &);
227bool ITKIOXML_EXPORT
228 operator==(itk::FancyString & s, const char *);
229bool ITKIOXML_EXPORT
231
232namespace itk
233{
235// manipulators for FancyString (currently only one is defined)
237
242operator<<(FancyString & s, void (*mf)(FancyString &));
243
247void
249
251// helper functions for converting a string to/from a std::vector
253
259template <typename T>
261operator>>(FancyString & s, std::vector<T> & data);
262
267template <typename T>
269operator<<(FancyString & s, const std::vector<T> & data);
270
272// helper functions for converting a string to/from a itk::Array
274
280template <typename T>
283
288template <typename T>
290operator<<(FancyString & s, const Array<T> & data);
291
293// helper functions for converting a string to/from a basic data type
295
300template <typename T>
302operator>>(FancyString & s, T & data);
303
308template <typename T>
310operator<<(FancyString & s, const T & data);
311
312} // namespace itk
313
314#ifndef ITK_MANUAL_INSTANTIATION
315# include "itkFancyString.hxx"
316#endif
317
318#endif // itkFancyString_h
Array class with size defined at construction time.
Definition: itkArray.h:48
A special string type that is used to aid I/O operations in DOM-based object readers/writers.
void Split(std::map< std::string, std::string > &result, const std::string &delims=";|")
FancyString & FromData(const std::vector< T > &inputData)
FancyString & ToLowerCase()
void Split(std::string &lpart, std::string &rpart, const std::string &delims="=:") const
FancyString & ToData(T &outputData)
FancyString & ToData(Array< T > &outputData, int count=-1)
FancyString & FromData(const Array< T > &inputData)
FancyString & TrimRight(const std::string &dislike=" \t\n\r")
bool StartWith(const std::string &s2, bool ignoreCase=true)
const std::string & ToString() const
FancyString & FromData(const T &inputData)
FancyString & operator=(const char *s)
std::string m_Value
FancyString(const char *s)
FancyString & TrimLeft(const std::string &dislike=" \t\n\r")
FancyString & ToData(std::vector< T > &outputData, int count=-1)
FancyString & Trim(const std::string &dislike=" \t\n\r")
void Append(const FancyString &str)
FancyString(const std::string &str)
bool ContainSub(const std::string &s2, bool ignoreCase=true)
bool MatchWith(const std::string &s2, bool ignoreCase=true)
void Split(std::vector< std::string > &result, const std::string &delims=";|") const
FancyString & operator=(const std::string &str)
bool EndWith(const std::string &s2, bool ignoreCase=true)
FancyString & ToUpperCase()
bool ITKIOXML_EXPORT operator==(itk::FancyString &s, const std::string &)
bool ITKIOXML_EXPORT operator!=(itk::FancyString &s, const std::string &)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
void ClearContent(FancyString &input)
std::istream & operator>>(std::istream &is, Point< T, VPointDimension > &vct)
ITKCommon_EXPORT std::ostream & operator<<(std::ostream &out, typename AnatomicalOrientation::CoordinateEnum value)