Loading...
Searching...
No Matches
stringUtils.hpp
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 *
3 * bitpit
4 *
5 * Copyright (C) 2015-2021 OPTIMAD engineering Srl
6 *
7 * -------------------------------------------------------------------------
8 * License
9 * This file is part of bitpit.
10 *
11 * bitpit is free software: you can redistribute it and/or modify it
12 * under the terms of the GNU Lesser General Public License v3 (LGPL)
13 * as published by the Free Software Foundation.
14 *
15 * bitpit is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18 * License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with bitpit. If not, see <http://www.gnu.org/licenses/>.
22 *
23\*---------------------------------------------------------------------------*/
24
25#ifndef __BITPIT_STRING_UTILS_HPP__
26#define __BITPIT_STRING_UTILS_HPP__
27
30#include <algorithm>
31#include <array>
32#include <functional>
33#include <iomanip>
34#include <iostream>
35#include <sstream>
36#include <string>
37#include <vector>
38
39namespace bitpit {
40
41namespace utils {
42
48namespace string {
49
50// Trimming operators
51inline std::string &ltrim(std::string &s);
52inline std::string &rtrim(std::string &s);
53inline std::string &trim(std::string &s);
54
55// Padding operators
56inline std::string lfill(int nchars, const std::string &s, char c);
57inline std::string rfill(int nchars, const std::string &s, char c);
58inline std::string zeroPadNumber(int nchars, int num);
59
60// Keyword search
61bool getAfterKeyword(const std::string &line, const std::string &key, char del, std::string &result);
62inline bool keywordInString(const std::string &line, const std::string &key);
63
64// Conversion
65template <class T>
66void convertString(std::string input, T &output);
67
68template <class T>
69void convertString(std::string input, std::vector<T> &output);
70
71template <class T, size_t n>
72void convertString(std::string input, std::array<T,n> &output);
73
74}
75
76}
77
78}
79
80// Template implementation
81#include "stringUtils.tpp"
82
83#endif
std::string & trim(std::string &s)
std::string rfill(int nchars, const std::string &s, char c)
std::string zeroPadNumber(int nchars, int num)
std::string & ltrim(std::string &s)
bool keywordInString(const std::string &line, const std::string &key)
std::string lfill(int nchars, const std::string &s, char c)
void convertString(std::string input, T &output)
bool getAfterKeyword(const std::string &line, const std::string &key, char del, std::string &result)
std::string & rtrim(std::string &s)
--- layout: doxygen_footer ---