Essentia  2.1-beta5-dev
stringutil.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2016 Music Technology Group - Universitat Pompeu Fabra
3  *
4  * This file is part of Essentia
5  *
6  * Essentia is free software: you can redistribute it and/or modify it under
7  * the terms of the GNU Affero General Public License as published by the Free
8  * Software Foundation (FSF), either version 3 of the License, or (at your
9  * option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14  * details.
15  *
16  * You should have received a copy of the Affero GNU General Public License
17  * version 3 along with this program. If not, see http://www.gnu.org/licenses/
18  */
19 
20 #ifndef ESSENTIA_STRINGUTIL_H
21 #define ESSENTIA_STRINGUTIL_H
22 
23 #include <vector>
24 #include <string>
25 #include <sstream>
26 
27 namespace essentia {
28 
32 std::string toLower(const std::string& str);
33 
37 std::string toUpper(const std::string& str);
38 
43 std::vector<std::string> tokenize(const std::string& str, const std::string& delimiters, bool trimEmpty = false);
44 
48 std::string strip(const std::string& str);
49 
50 
54 class Stringifier {
55  protected:
56  std::ostringstream oss;
57 
58  public:
59  template <typename T>
60  Stringifier& operator<<(const T& msg) { oss << msg; return *this; }
61 
62  std::string str() const { return oss.str(); }
63 };
64 
65 
66 std::string pad(int n, int size, char paddingChar=' ', bool leftPadded=false);
67 std::string pad(const std::string& str, int size, char paddingChar=' ', bool leftPadded=false);
68 
69 
70 } // namespace essentia
71 
72 #endif // ESSENTIA_STRINGUTIL_H
std::string strip(const std::string &str)
std::ostringstream oss
Definition: stringutil.h:56
std::string toLower(const std::string &str)
std::string pad(int n, int size, char paddingChar=' ', bool leftPadded=false)
Stringifier & operator<<(const T &msg)
Definition: stringutil.h:60
Definition: algorithm.h:28
std::string toUpper(const std::string &str)
Definition: stringutil.h:54
std::vector< std::string > tokenize(const std::string &str, const std::string &delimiters, bool trimEmpty=false)
std::string str() const
Definition: stringutil.h:62