/* belcard_property.hpp Copyright (C) 2015 Belledonne Communications SARL This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #ifndef belcard_property_hpp #define belcard_property_hpp #include #include #include "belcard_utils.hpp" #include "belcard/belcard_generic.hpp" #include "belcard_params.hpp" #include "belcard/belcard_parser.hpp" #include #include #include namespace belcard { class BelCardProperty : public BelCardGeneric { protected: std::string _group; std::string _name; std::string _value; std::shared_ptr _lang_param; std::shared_ptr _value_param; std::shared_ptr _pref_param; std::shared_ptr _altid_param; std::shared_ptr _pid_param; std::shared_ptr _type_param; std::shared_ptr _mediatype_param; std::shared_ptr _calscale_param; std::shared_ptr _sort_as_param; std::shared_ptr _geo_param; std::shared_ptr _tz_param; std::list> _params; public: template static std::shared_ptr parseProperty(const std::string& rule, const std::string& input) { size_t parseLength; std::shared_ptr parser = BelCardParser::getInstance(); std::shared_ptr ret = parser->_parser->parseInput(rule, input, &parseLength); // -2 because the input is terminated by a new line. return ret && parseLength == input.length() - 2 ? std::dynamic_pointer_cast(ret) : nullptr; } BELCARD_PUBLIC static std::shared_ptr parse(const std::string& input); BELCARD_PUBLIC static void setHandlerAndCollectors(belr::Parser> *parser); BELCARD_PUBLIC BelCardProperty(); BELCARD_PUBLIC virtual void setGroup(const std::string &group); BELCARD_PUBLIC virtual const std::string &getGroup() const; BELCARD_PUBLIC virtual void setName(const std::string &name); BELCARD_PUBLIC virtual const std::string &getName() const; BELCARD_PUBLIC virtual void setValue(const std::string &value); BELCARD_PUBLIC virtual const std::string &getValue() const; BELCARD_PUBLIC virtual void setLanguageParam(const std::shared_ptr ¶m); BELCARD_PUBLIC virtual const std::shared_ptr &getLanguageParam() const; BELCARD_PUBLIC virtual void setValueParam(const std::shared_ptr ¶m); BELCARD_PUBLIC virtual const std::shared_ptr &getValueParam() const; BELCARD_PUBLIC virtual void setPrefParam(const std::shared_ptr ¶m); BELCARD_PUBLIC virtual const std::shared_ptr &getPrefParam() const; BELCARD_PUBLIC virtual void setAlternativeIdParam(const std::shared_ptr ¶m); BELCARD_PUBLIC virtual const std::shared_ptr &getAlternativeIdParam() const; BELCARD_PUBLIC virtual void setParamIdParam(const std::shared_ptr ¶m); BELCARD_PUBLIC virtual const std::shared_ptr &getParamIdParam() const; BELCARD_PUBLIC virtual void setTypeParam(const std::shared_ptr ¶m); BELCARD_PUBLIC virtual const std::shared_ptr &getTypeParam() const; BELCARD_PUBLIC virtual void setMediaTypeParam(const std::shared_ptr ¶m); BELCARD_PUBLIC virtual const std::shared_ptr &getMediaTypeParam() const; BELCARD_PUBLIC virtual void setCALSCALEParam(const std::shared_ptr ¶m); BELCARD_PUBLIC virtual const std::shared_ptr &getCALSCALEParam() const; BELCARD_PUBLIC virtual void setSortAsParam(const std::shared_ptr ¶m); BELCARD_PUBLIC virtual const std::shared_ptr &getSortAsParam() const; BELCARD_PUBLIC virtual void setGeoParam(const std::shared_ptr ¶m); BELCARD_PUBLIC virtual const std::shared_ptr &getGeoParam() const; BELCARD_PUBLIC virtual void setTimezoneParam(const std::shared_ptr ¶m); BELCARD_PUBLIC virtual const std::shared_ptr &getTimezoneParam() const; BELCARD_PUBLIC virtual void addParam(const std::shared_ptr ¶m); BELCARD_PUBLIC virtual const std::list> &getParams() const; BELCARD_PUBLIC virtual void removeParam(const std::shared_ptr ¶m); BELCARD_PUBLIC virtual void serialize(std::ostream &output) const; }; } #endif