Go to the documentation of this file.00001 #ifndef FCAM_TAGVALUE_H
00002 #define FCAM_TAGVALUE_H
00003
00004 #include <string>
00005 #include <vector>
00006
00007 #include "Time.h"
00008 #include "Event.h"
00009
00013 namespace FCam {
00014
00016 class TagValue {
00017
00018 public:
00021 enum Type {
00022 Null = 0,
00023 Int,
00024 Float,
00025 Double,
00026 String,
00027 Time,
00028 IntVector,
00029 FloatVector,
00030 DoubleVector,
00031 StringVector,
00032 TimeVector
00033 };
00034
00035 ~TagValue();
00036
00043
00044 TagValue();
00045 TagValue(int);
00046 TagValue(float);
00047 TagValue(double);
00048 TagValue(std::string);
00049 TagValue(FCam::Time);
00050 TagValue(std::vector<int>);
00051 TagValue(std::vector<float>);
00052 TagValue(std::vector<double>);
00053 TagValue(std::vector<std::string>);
00054 TagValue(std::vector<FCam::Time>);
00055 TagValue(const TagValue &);
00057
00064 const TagValue &operator=(const int &);
00065 const TagValue &operator=(const float &);
00066 const TagValue &operator=(const double &);
00067 const TagValue &operator=(const std::string &);
00068 const TagValue &operator=(const FCam::Time &);
00069 const TagValue &operator=(const std::vector<int> &);
00070 const TagValue &operator=(const std::vector<float> &);
00071 const TagValue &operator=(const std::vector<double> &);
00072 const TagValue &operator=(const std::vector<std::string> &);
00073 const TagValue &operator=(const std::vector<FCam::Time> &);
00074 const TagValue &operator=(const TagValue &);
00076
00097 operator int &() const;
00098 operator float &() const;
00099 operator double &() const;
00100 operator std::string &() const;
00101 operator FCam::Time &() const;
00102 operator std::vector<int> &() const;
00103 operator std::vector<float> &() const;
00104 operator std::vector<double> &() const;
00105 operator std::vector<std::string> &() const;
00106 operator std::vector<FCam::Time> &() const;
00108
00124
00125 int &asInt() {return *this;}
00126 float &asFloat() {return *this;}
00127 double &asDouble() {return *this;}
00128 std::string &asString() {return *this;}
00129 FCam::Time &asTime() {return *this;}
00130 std::vector<int> &asIntVector() {return *this;}
00131 std::vector<float> &asFloatVector() {return *this;}
00132 std::vector<double> &asDoubleVector() {return *this;}
00133 std::vector<std::string> &asStringVector() {return *this;}
00134 std::vector<FCam::Time> &asTimeVector() {return *this;}
00135
00137
00138
00140 bool valid() { return type != Null; }
00141
00143 std::string toString() const;
00144
00149 std::string toBlob();
00150
00152 static TagValue fromString(const std::string &);
00153
00155 Type type;
00156
00158 void *data;
00159
00160 private:
00161 void nullify();
00162
00163
00164
00165
00166 static int dummyInt;
00167 static float dummyFloat;
00168 static double dummyDouble;
00169 static std::string dummyString;
00170 static FCam::Time dummyTime;
00171 static std::vector<int> dummyIntVector;
00172 static std::vector<float> dummyFloatVector;
00173 static std::vector<double> dummyDoubleVector;
00174 static std::vector<std::string> dummyStringVector;
00175 static std::vector<FCam::Time> dummyTimeVector;
00176
00177 };
00178
00181 std::ostream & operator<<(std::ostream& out, const TagValue &t);
00182
00185 std::istream & operator>>(std::istream& in, TagValue &t);
00186
00187 }
00188
00189 #endif