All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
CasePipe.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_CASE_PIPE_H_INCLUDED
16 #define HEXT_CASE_PIPE_H_INCLUDED
17 
18 /// @file
19 /// Declares hext::CasePipe
20 
21 #include "hext/Cloneable.h"
22 #include "hext/StringPipe.h"
23 
24 #include <string>
25 
26 
27 namespace hext {
28 
29 
30 /// Changes the case of a string. Changes to lower case by default.
31 class CasePipe final : public hext::Cloneable<CasePipe, StringPipe>
32 {
33 public:
34  /// CasePipe's options.
35  enum Option
36  {
37  ToLower = 1 << 1,
38  ToUpper = 1 << 2
39  };
40 
41  /// Constructs a CasePipe.
42  ///
43  /// @param option: Change the string to this case. Default: to lower case.
44  explicit CasePipe(Option option = Option::ToLower) noexcept;
45 
46  /// Changes the case of str.
47  std::string transform(std::string str) const override;
48 
49 private:
50  Option option_;
51 };
52 
53 
54 } // namespace hext
55 
56 
57 #endif // HEXT_CASE_PIPE_H_INCLUDED
58 
std::string transform(std::string str) const override
Changes the case of str.
Declares hext::StringPipe.
CasePipe(Option option=Option::ToLower) noexcept
Constructs a CasePipe.
Option
CasePipe's options.
Definition: CasePipe.h:35
Curiously recurring template pattern that extends a base class to provide a virtual method Cloneable:...
Definition: Cloneable.h:34
Defines template hext::Cloneable.
Changes the case of a string. Changes to lower case by default.
Definition: CasePipe.h:31