ITK  4.6.0
Insight Segmentation and Registration Toolkit
itkStringTools.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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  * http://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 
26 namespace itk
27 {
28 
39 {
40 public:
42  // helper functions for converting a string to/from a std::vector
44 
54  template < typename T >
55  static std::string& ToData( std::string& s, std::vector<T>& data, int count = -1 );
57 
62  template < typename T >
63  static std::string& FromData( std::string& s, const std::vector<T>& data );
64 
66  // helper functions for converting a string to/from a itk::Array
68 
78  template < typename T >
79  static std::string& ToData( std::string& s, Array<T>& data, int count = -1 );
81 
86  template < typename T >
87  static std::string& FromData( std::string& s, const Array<T>& data );
88 
90  // helper functions for converting a string to/from a basic data type
92 
97  template < typename T >
98  static std::string& ToData( std::string& s, T& data );
99 
104  template < typename T >
105  static std::string& FromData( std::string& s, const T& data );
106 
108  // helper functions for string manipulations
110 
112  static std::string& Trim( std::string& str, const std::string& dislike = " \t\n\r" );
113 
115  static std::string& TrimLeft( std::string& str, const std::string& dislike = " \t\n\r" );
116 
118  static std::string& TrimRight( std::string& str, const std::string& dislike = " \t\n\r" );
119 
121  static std::string& ToUpperCase( std::string& str );
122 
124  static std::string& ToLowerCase( std::string& str );
125 
127  static void Split( const std::string& s, std::string& lpart, std::string& rpart, const std::string& delims = "=:" );
128 
130  static void Split( const std::string& s, std::vector<std::string>& result, const std::string& delims = ";|" );
131 
136  static void Split( const std::string& s, std::map<std::string,std::string>& result, const std::string& delims = ";|" );
137 
139  static bool MatchWith( const std::string& s1, const std::string& s2, bool ignoreCase = true );
140 
142  static bool StartWith( const std::string& s1, const std::string& s2, bool ignoreCase = true );
143 
145  static bool EndWith( const std::string& s1, const std::string& s2, bool ignoreCase = true );
146 
148  static bool ContainSub( const std::string& s1, const std::string& s2, bool ignoreCase = true );
149 }; // class StringTools
150 
151 } // namespace itk
152 
153 #ifndef ITK_MANUAL_INSTANTIATION
154 #include "itkStringTools.hxx"
155 #endif
156 
157 #endif // __itkStringTools_h
static bool ContainSub(const std::string &s1, const std::string &s2, bool ignoreCase=true)
Array class with size defined at construction time.
Definition: itkArray.h:50
static std::string & Trim(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 bool EndWith(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")
A set of tools to manipulate a string.
static bool StartWith(const std::string &s1, const std::string &s2, bool ignoreCase=true)
static std::string & ToLowerCase(std::string &str)
static std::string & ToData(std::string &s, std::vector< T > &data, int count=-1)
static std::string & FromData(std::string &s, const std::vector< T > &data)
static bool MatchWith(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 & ToUpperCase(std::string &str)