00001 #ifndef __INSTANTIO_VARIABLEREPLACER_H
00002 #define __INSTANTIO_VARIABLEREPLACER_H
00003
00004 #ifdef _MSC_VER
00005 # pragma once
00006 #endif
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "InstantIODef.h"
00027 #include <vector>
00028 #include <string>
00029 namespace Config
00030 {
00031 class ParamBag;
00032 }
00033 #ifdef _MSC_VER
00034 # pragma warning (push)
00035 # pragma warning (disable: 4251)
00036 #endif
00037
00038
00039 namespace InstantIO
00040 {
00041
00042
00077 class INSTANTIO_DLLMAPPING VariableReplacer
00078 {
00079 public:
00080
00085 inline VariableReplacer(): format_() {}
00086
00092 inline VariableReplacer(const std::string &format): format_()
00093 { setFormat(format); }
00094
00096 ~VariableReplacer();
00097
00102 void setFormat(const std::string &format);
00103
00105 void clear();
00106
00119 std::string toString(const Config::ParamBag ¶ms) const;
00120
00121 private:
00122
00127 class Element
00128 {
00129 public:
00130
00132 virtual ~Element();
00133
00139 virtual std::string toString(const Config::ParamBag ¶ms) const = 0;
00140 };
00141
00146 class Variable: public Element
00147 {
00148 public:
00149
00154 inline Variable(const std::string &name)
00155 : Element(), name_(name)
00156 {}
00157
00159 virtual ~Variable();
00160
00170 virtual std::string toString(const Config::ParamBag ¶ms) const;
00171
00172 private:
00173
00175 std::string name_;
00176 };
00177
00182 class Text: public Element
00183 {
00184 public:
00185
00190 inline Text(const std::string &text)
00191 : Element(), text_(text)
00192 {}
00193
00195 virtual ~Text();
00196
00203 virtual std::string toString(const Config::ParamBag ¶ms) const;
00204
00205 private:
00206
00208 std::string text_;
00209 };
00210
00212 std::vector<Element*> format_;
00213
00221 std::string stripEscapes(const std::string &s) const;
00222 };
00223
00224
00225 }
00226
00227
00228 #ifdef _MSC_VER
00229 # pragma warning (pop)
00230 #endif
00231
00232 #endif // __INSTANTIO_VARIABLEREPLACER_H