libhext: C++ Library Documentation 1.0.13-b24695d
Loading...
Searching...
No Matches
TrimPipe.h
Go to the documentation of this file.
1// Copyright 2015, 2016 Thomas Trapp
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#ifndef HEXT_TRIM_PIPE_H_INCLUDED
16#define HEXT_TRIM_PIPE_H_INCLUDED
17
18/// @file
19/// Declares hext::TrimPipe
20
21#include "hext/Cloneable.h"
22#include "hext/StringPipe.h"
23#include "hext/Visibility.h"
24
25#include <string>
26
27
28namespace hext {
29
30
31/// Trims characters from the beginning and end of a string. Trims space by
32/// default.
33class HEXT_PUBLIC TrimPipe final : public hext::Cloneable<TrimPipe, StringPipe>
34{
35public:
36 /// Constructs a TrimPipe.
37 ///
38 /// @param trim_any_of: Trim any of these characters from beginning or end
39 /// of the string. Default: Trim spaces.
40 explicit TrimPipe(std::string trim_any_of = " ");
41
42 /// Removes all left and right characters that were given in the constructor
43 /// from str.
44 std::string transform(std::string str) const override;
45
46private:
47 std::string trim_any_of_;
48};
49
50
51} // namespace hext
52
53
54#endif // HEXT_TRIM_PIPE_H_INCLUDED
55
Defines template hext::Cloneable.
Declares hext::StringPipe.
Defines HEXT_PUBLIC and HEXT_PRIVATE.
#define HEXT_PUBLIC
Definition Visibility.h:26
Curiously recurring template pattern that extends a base class to provide a virtual method Cloneable:...
Definition Cloneable.h:37
Trims characters from the beginning and end of a string.
Definition TrimPipe.h:34
std::string transform(std::string str) const override
Removes all left and right characters that were given in the constructor from str.
TrimPipe(std::string trim_any_of=" ")
Constructs a TrimPipe.