eDSP  0.0.1
A cross-platform DSP library written in C++.
trim.hpp
Go to the documentation of this file.
1 /*
2  * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3  * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4  *
5  * This program is free software: you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License as published by the Free
7  * Software Foundation, either version 3 of the License, or (at your option)
8  * any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along width
16  * this program. If not, see <http://www.gnu.org/licenses/>
17  *
18  * File: trim.hpp
19  * Author: Mohammed Boujemaoui
20  * Date: 05/10/2018
21  */
22 #ifndef EDSP_TRIM_HPP
23 #define EDSP_TRIM_HPP
24 
25 #include <edsp/meta/iterator.hpp>
26 #include <sstream>
27 #include <algorithm>
28 
29 namespace edsp { namespace string {
30 
35  template <typename Char>
36  inline void ltrim(std::basic_string<Char>& str) {
37  str.erase(std::begin(str), std::find_if(std::begin(str), std::end(str),
38  [](Char character) { return !std::isspace(character); }));
39  }
40 
45  template <typename Char>
46  inline void rtrim(std::basic_string<Char>& str) {
47  str.erase(
48  std::find_if(std::rbegin(str), std::rend(str), [](Char character) { return !std::isspace(character); })
49  .base(),
50  std::end(str));
51  }
52 
57  template <typename Char>
58  inline void trim(std::basic_string<Char>& str) {
59  ltrim(str);
60  rtrim(str);
61  };
62 
63 }} // namespace edsp::string
64 
65 #endif //EDSP_TRIM_HPP
void ltrim(std::basic_string< Char > &str)
Filters the leading whitespace of the input string.
Definition: trim.hpp:36
void trim(std::basic_string< Char > &str)
Filters the leading and trailing whitespace of the input string.
Definition: trim.hpp:58
void rtrim(std::basic_string< Char > &str)
Filters the trailing whitespace of the last position of the input string.
Definition: trim.hpp:46
Definition: amplifier.hpp:29