SDXFrameWork  0.07
SDXFrameWork
 全て クラス ネームスペース 関数 変数 列挙型 列挙型の値 ページ
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 
57  class VString
58  {
59  private:
60  std::string 文字列;
61 
62  template < class TFirst, typename ... TRest>
63  void Change(std::ostringstream& 文字列, TFirst 最初の要素, TRest... 残りの要素)
64  {
65  文字列 << 最初の要素;
66  Change(文字列, 残りの要素...);
67  }
68 
69  template < class TFirst>
70  void Change(std::ostringstream& 文字列, TFirst 最初の要素)
71  {
72  文字列 << 最初の要素;
73  }
74 
75  public:
76  template < typename ... TStream>
77  VString( TStream... 文字列ストリーム)
78  {
79  std::ostringstream 文字バッファ;
80  Change( 文字バッファ , 文字列ストリーム...);
81  文字列 = 文字バッファ.str();
82  }
83 
84  const char* c_str()
85  {
86  return 文字列.c_str();
87  }
88  };
89 }
Definition: VariadicStream.h:57
可変数引数な文字列を処理するクラス.
Definition: VariadicStream.h:8