00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef CDMATTRIBUTE_H_
00025 #define CDMATTRIBUTE_H_
00026
00027 #include<string>
00028 #include<vector>
00029 #include<ostream>
00030 #include<boost/shared_ptr.hpp>
00031 #include "fimex/CDMDataType.h"
00032 #include "fimex/CDMNamedEntity.h"
00033 #include "fimex/CDMException.h"
00034
00035 namespace MetNoFimex
00036 {
00037
00038 class Data;
00039
00040 class CDMAttribute : public CDMNamedEntity
00041 {
00042
00043 public:
00044 CDMAttribute();
00046 explicit CDMAttribute(std::string name, std::string value);
00048 explicit CDMAttribute(std::string name, char value);
00050 explicit CDMAttribute(std::string name, int value);
00052 explicit CDMAttribute(std::string name, short value);
00054 explicit CDMAttribute(std::string name, float value);
00056 explicit CDMAttribute(std::string name, double value);
00058 explicit CDMAttribute(std::string name, CDMDataType datatype, boost::shared_ptr<Data> data);
00060 explicit CDMAttribute(const std::string& name, const std::string& datatype, const std::string& value) throw(CDMException);
00062 explicit CDMAttribute(const std::string& name, CDMDataType datatype, const std::vector<std::string>& values) throw(CDMException);
00063 virtual ~CDMAttribute();
00065 const std::string& getName() const {return name;}
00067 void setName(std::string newName) {name = newName;}
00069 const std::string getStringValue() const;
00071 const boost::shared_ptr<Data> getData() const {return data;}
00073 void setData(boost::shared_ptr<Data> data) {this->data = data;}
00075 const CDMDataType getDataType() const {return datatype;}
00076 void toXMLStream(std::ostream& out) const;
00077 private:
00078 std::string name;
00079 CDMDataType datatype;
00080 boost::shared_ptr<Data> data;
00081
00082 void initDataByArray(const std::vector<std::string>& values);
00083
00084 template<typename T>
00085 void initDataArray(const std::vector<std::string>& values);
00086 };
00087
00093 std::vector<CDMAttribute> projStringToAttributes(std::string projStr);
00100 std::string attributesToProjString(const std::vector<CDMAttribute>& attrs);
00101
00102
00103 }
00104
00105 #endif