Loading...
Searching...
No Matches
StreamBuilder.h
1/*
2
3MIT License
4
5Copyright (c) 2017 FMI Open Development / Markus Peura, first.last@fmi.fi
6
7Permission is hereby granted, free of charge, to any person obtaining a copy
8of this software and associated documentation files (the "Software"), to deal
9in the Software without restriction, including without limitation the rights
10to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11copies of the Software, and to permit persons to whom the Software is
12furnished to do so, subject to the following conditions:
13
14The above copyright notice and this permission notice shall be included in all
15copies or substantial portions of the Software.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23SOFTWARE.
24
25*/
26/*
27Part of Rack development has been done in the BALTRAD projects part-financed
28by the European Union (European Regional Development Fund and European
29Neighbourhood Partnership Instrument, Baltic Sea Region Programme 2007-2013)
30*/
31/*
32 * StringTools.h
33 *
34 * Created on: Feb, 2022
35 * Author: mpeura
36 */
37
38#ifndef DRAIN_STREAM_BUILDER
39#define DRAIN_STREAM_BUILDER
40
41/*
42#include <limits>
43#include <iterator>
44#include <sstream>
45#include <iostream>
46#include <list>
47#include <map>
48*/
49
50//#include "RegExp.h"
51#include <iostream>
52#include <string>
53#include <sstream>
54
55namespace drain {
56
57// TODO:
58template <char SEP=0>
59class StreamBuilder : public std::stringstream {
60
61public:
62
63 template<typename ... TT>
64 StreamBuilder(const TT &... args){
65 create(args...);
66 }
67
68 template<typename ... TT>
69 StreamBuilder & create(const TT &... args) {
70 std::stringstream::str("");
71 return add(args...);
72 }
73
74 template<class T, typename ... TT>
75 StreamBuilder & add(const T & arg, const TT &... args) {
76 if (SEP && (tellp() > 0)){
77 *this << (SEP);
78 }
79 *this << arg;
80 return add(args...);
81 }
82
83 /*
84 template<Enum E, typename ... TT>
85 StreamBuilder & add(const E & arg, const TT &... args) {
86 if (SEP && (tellp() > 0)){
87 *this << (SEP);
88 }
89 *this << arg;
90 return add(args...);
91 }
92 */
93
94
95protected:
96
97 /*
98 template<class T, typename ... TT>
99 StreamBuilder & addSeparated(const T & arg, const TT &... args) {
100 if (SEP){
101 *this << (SEP);
102 }
103 *this << arg;
104 return addSeparated(args...);
105 }
106
107 // Terminal
108 inline
109 StreamBuilder & addSeparated(){
110 return *this;
111 };
112 */
113
114 // Terminal
115 inline
116 StreamBuilder & add(){
117 return *this;
118 };
119
120};
121
122
123} // drain::
124
125#endif /* DRAIN_STREAM_BUILDER */
126
Definition StreamBuilder.h:59
Definition DataSelector.cpp:1277