SDXFrameWork  0.09
SDXFrameWork
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
VariadicStream.h
1 #pragma once
2 #include <sstream>
3 #include <iostream>
4 
5 namespace SDX
6 {
9  {
10  private:
11  template < typename ... TRest>
12  std::string Change(TRest... 残りの要素)
13  {
14  std::ostringstream os;
15 
16  Change( os , 残りの要素...);
17 
18  return os.str();
19  }
20 
21  template < class TFirst, typename ... TRest>
22  void Change(std::ostringstream& 文字列, TFirst 最初の要素, TRest... 残りの要素)
23  {
24  文字列 << 最初の要素;
25  Change(文字列, 残りの要素...);
26  }
27 
28  template < class TFirst>
29  void Change(std::ostringstream& 文字列, TFirst 最初の要素)
30  {
31  文字列 << 最初の要素;
32  }
33 
34  public:
35  std::vector<std::string> StringS;
36 
37  template < typename ... TStream>
38  VariadicStream( TStream... 文字列ストリーム)
39  {
40  std::string 分割する文字列 = Change(文字列ストリーム...);
41 
42  size_t 開始位置 = 0;
43  size_t 終了位置 = 0;
44 
45  //改行コードで区切る
46  while ( 終了位置 != std::string::npos )
47  {
48  終了位置 = 分割する文字列.find("\n", 開始位置);
49 
50  StringS.push_back(分割する文字列.substr(開始位置, 終了位置 - 開始位置));
51 
52  開始位置 = 終了位置 + 1;
53  }
54  }
55  };
56 }
可変数引数な文字列を処理するクラス.
Definition: VariadicStream.h:8