From 537f02b26d822a9760e033908b377b4cd444b553 Mon Sep 17 00:00:00 2001 From: Ake Hedman Date: Thu, 12 Oct 2023 10:32:26 +0200 Subject: [PATCH] Added som extra getter/setters --- src/vscp/common/mdf.cpp | 40 +++++++------- src/vscp/common/mdf.h | 113 +++++++++++++++++++++++++++++++++------- 2 files changed, 113 insertions(+), 40 deletions(-) diff --git a/src/vscp/common/mdf.cpp b/src/vscp/common/mdf.cpp index bb43c87e1..c5522b8ca 100644 --- a/src/vscp/common/mdf.cpp +++ b/src/vscp/common/mdf.cpp @@ -847,7 +847,7 @@ CMDF_Event::clearStorage() CMDF_Item::CMDF_Item() : CMDF_Object(mdf_type_value_item) { - m_name.clear(); + m_value.clear(); } CMDF_Item::~CMDF_Item() @@ -3532,7 +3532,7 @@ __handleMDFParserData(void *data, const XML_Char *content, int length) spdlog::trace("Parse-XML: handleMDFParserData: Module manufacturer address telephone number: {0}", strContent); vscp_trim(strContent); vscp_makeLower(strContent); - gpItemStruct->m_name = strContent; + gpItemStruct->m_value = strContent; } else if (gTokenList.at(0) == "description") { spdlog::trace( @@ -3548,7 +3548,7 @@ __handleMDFParserData(void *data, const XML_Char *content, int length) spdlog::trace("Parse-XML: handleMDFParserData: Module manufacturer address fax number: {0}", strContent); vscp_trim(strContent); vscp_makeLower(strContent); - gpItemStruct->m_name = strContent; + gpItemStruct->m_value = strContent; } else if (gTokenList.at(0) == "description") { spdlog::trace("Parse-XML: handleMDFParserData: Module manufacturer address fax description: {0} Language: {1}", @@ -3563,7 +3563,7 @@ __handleMDFParserData(void *data, const XML_Char *content, int length) spdlog::trace("Parse-XML: handleMDFParserData: Module manufacturer email address: {0}", strContent); vscp_trim(strContent); vscp_makeLower(strContent); - gpItemStruct->m_name = strContent; + gpItemStruct->m_value = strContent; } else if (gTokenList.at(0) == "description") { spdlog::trace( @@ -3579,7 +3579,7 @@ __handleMDFParserData(void *data, const XML_Char *content, int length) spdlog::trace("Parse-XML: handleMDFParserData: Module manufacturer web address: {0}", strContent); vscp_trim(strContent); vscp_makeLower(strContent); - gpItemStruct->m_name = strContent; + gpItemStruct->m_value = strContent; } else if (gTokenList.at(0) == "description") { spdlog::trace( @@ -3595,7 +3595,7 @@ __handleMDFParserData(void *data, const XML_Char *content, int length) spdlog::trace("Parse-XML: handleMDFParserData: Module manufacturer social address: {0}", strContent); vscp_trim(strContent); vscp_makeLower(strContent); - gpItemStruct->m_name = strContent; + gpItemStruct->m_value = strContent; } else if (gTokenList.at(0) == "description") { spdlog::trace( @@ -5512,8 +5512,8 @@ CMDF::parseMDF_JSON(const std::string &path) json jsub2 = phone.value(); if (jsub2.contains("number") && jsub2["number"].is_string()) { - ptel->m_name = jsub2["number"]; - spdlog::debug("Parse-JSON: Module manufacturer telephone: {0}", ptel->m_name); + ptel->m_value = jsub2["number"]; + spdlog::debug("Parse-JSON: Module manufacturer telephone: {0}", ptel->m_value); } // Description is language specific. Can be string or object @@ -5545,8 +5545,8 @@ CMDF::parseMDF_JSON(const std::string &path) json jsub2 = fax.value(); if (jsub2.contains("number") && jsub2["number"].is_string()) { - pfax->m_name = jsub2["number"]; - spdlog::debug("Parse-JSON: Module manufacturer fax: {0}", pfax->m_name); + pfax->m_value = jsub2["number"]; + spdlog::debug("Parse-JSON: Module manufacturer fax: {0}", pfax->m_value); } // Description is language specific. Can be string or object @@ -5578,8 +5578,8 @@ CMDF::parseMDF_JSON(const std::string &path) json jsub2 = email.value(); if (jsub2.contains("address") && jsub2["address"].is_string()) { - pemail->m_name = jsub2["address"]; - spdlog::debug("Parse-JSON: Module manufacturer email: {0}", pemail->m_name); + pemail->m_value = jsub2["address"]; + spdlog::debug("Parse-JSON: Module manufacturer email: {0}", pemail->m_value); } // Description is language specific. Can be string or object @@ -5611,12 +5611,12 @@ CMDF::parseMDF_JSON(const std::string &path) json jsub2 = web.value(); if (jsub2.contains("url") && jsub2["url"].is_string()) { - pweb->m_name = jsub2["url"]; - spdlog::debug("Parse-JSON: Module manufacturer web: {0}", pweb->m_name); + pweb->m_value = jsub2["url"]; + spdlog::debug("Parse-JSON: Module manufacturer web: {0}", pweb->m_value); } else if (jsub2.contains("address") && jsub2["address"].is_string()) { - pweb->m_name = jsub2["address"]; - spdlog::debug("Parse-JSON: Module manufacturer web: {0}", pweb->m_name); + pweb->m_value = jsub2["address"]; + spdlog::debug("Parse-JSON: Module manufacturer web: {0}", pweb->m_value); } else { spdlog::warn("Parse-JSON: No web url/address."); @@ -5651,12 +5651,12 @@ CMDF::parseMDF_JSON(const std::string &path) json jsub2 = social.value(); if (jsub2.contains("url") && jsub2["url"].is_string()) { - psocial->m_name = jsub2["url"]; - spdlog::debug("Parse-JSON: Module manufacturer web: {0}", psocial->m_name); + psocial->m_value = jsub2["url"]; + spdlog::debug("Parse-JSON: Module manufacturer web: {0}", psocial->m_value); } else if (jsub2.contains("address") && jsub2["address"].is_string()) { - psocial->m_name = jsub2["id"]; - spdlog::debug("Parse-JSON: Module manufacturer web: {0}", psocial->m_name); + psocial->m_value = jsub2["id"]; + spdlog::debug("Parse-JSON: Module manufacturer web: {0}", psocial->m_value); } else { spdlog::warn("Parse-JSON: No social url/address."); diff --git a/src/vscp/common/mdf.h b/src/vscp/common/mdf.h index e47d6400e..32e4ec05a 100644 --- a/src/vscp/common/mdf.h +++ b/src/vscp/common/mdf.h @@ -103,6 +103,7 @@ typedef enum mdf_file_type { typedef enum mdf_record_type { mdf_type_unknown, mdf_type_mdf, + mdf_type_mdf_item, mdf_type_value, mdf_type_value_item, mdf_type_bit, @@ -121,9 +122,27 @@ typedef enum mdf_record_type { mdf_type_event_data, mdf_type_event_data_item, mdf_type_bootloader, + mdf_type_bootloader_item, mdf_type_address, mdf_type_manufacturer, + mdf_type_manufacturer_item, + mdf_type_manufacturer_contact_phone, + mdf_type_manufacturer_contact_fax, + mdf_type_manufacturer_contact_email, + mdf_type_manufacturer_contact_web, + mdf_type_manufacturer_contact_social, + mdf_type_email, + mdf_type_email_item, + mdf_type_phone, + mdf_type_phone_item, + mdf_type_fax, + mdf_type_fax_item, + mdf_type_web, + mdf_type_web_item, + mdf_type_social, + mdf_type_social_item, mdf_type_file, + mdf_type_file_item, mdf_type_picture, mdf_type_picture_item, mdf_type_video, @@ -136,12 +155,7 @@ typedef enum mdf_record_type { mdf_type_setup_item, mdf_type_manual, mdf_type_manual_item, - mdf_type_redirection, - mdf_type_email, - mdf_type_phone, - mdf_type_fax, - mdf_type_web, - mdf_type_social, + mdf_type_redirection, mdf_type_alarm, mdf_type_generic_string, // Used for direct item editing mdf_type_generic_number, // Used for direct item editing @@ -182,6 +196,9 @@ class CMDF_Object { */ std::string getObjectTypeString(void); + virtual std::map *getMapDescription(void) { return nullptr; }; + virtual std::map *getMapInfoUrl(void) {return nullptr; }; + private: mdf_record_type m_type; }; @@ -951,7 +968,7 @@ class CMDF_RemoteVariable : public CMDF_Object { /*! Get Foreground color for VSCP Works grid. - @return Fourground color. + @return Forgrund color. */ uint32_t getForegroundColor(void) { return m_fgcolor; }; @@ -1626,10 +1643,16 @@ class CMDF_Item : public CMDF_Object { friend void __endSetupMDFParser(void *data, const char *name); /*! - Get bit array name - @return Bit array name + Get item value (***Deprecated use getValue()***) + @return Value */ - std::string getName(void) { return m_name; }; + std::string getName(void) { return m_value; }; + + /*! + Get item value + @return Value + */ + std::string getValue(void) { return m_value; }; /*! Get the register description @@ -1670,7 +1693,7 @@ class CMDF_Item : public CMDF_Object { std::map *getInfoUrlMap(void) { return &m_mapInfoURL; }; private: - std::string m_name; + std::string m_value; // Item value std::map m_mapDescription; std::map m_mapInfoURL; // Url that contain extra hel information }; @@ -1761,23 +1784,47 @@ class CMDF_Address : public CMDF_Object { */ std::string getStreet(void) { return m_strStreet; }; + /*! + Set street address + @param Street address to set + */ + void setStreet(const std::string& str) { m_strStreet = str; }; + /*! Get town address @return Town address */ std::string getTown(void) { return m_strTown; }; + /*! + Set town address + @param str Town address to set + */ + void setTown(const std::string& str) { m_strTown = str; }; + /*! Get city address @return City address */ std::string getCity(void) { return m_strCity; }; + /*! + Set city address + @param str City address to set + */ + void setCity(const std::string& str) { m_strCity = str; }; + /*! Get post code address @return Post code address */ - std::string getPostCode(void) { return m_strState; }; + std::string getPostCode(void) { return m_strPostCode; }; + + /*! + Set post code address + @param str Post code address to set + */ + void setPostCode(const std::string& str) { m_strPostCode = str; }; /*! Get state address @@ -1785,18 +1832,36 @@ class CMDF_Address : public CMDF_Object { */ std::string getState(void) { return m_strState; }; + /*! + Set state address + @param str State address to set + */ + void setState(const std::string& str) { m_strState = str; }; + /*! Get region address @return Region address */ std::string getRegion(void) { return m_strRegion; }; + /*! + Set region address + @param str Region address to set + */ + void setRegion(const std::string& str) { m_strRegion = str; }; + /*! Get country address @return Country address */ std::string getCountry(void) { return m_strCountry; }; + /*! + Set country address + @param str Country address to set + */ + void setCountry(const std::string& str) { m_strCountry = str; }; + private: std::string m_strStreet; std::string m_strTown; @@ -1835,6 +1900,15 @@ class CMDF_Manufacturer : public CMDF_Object { */ void clearStorage(void); + /// Get company name + std::string& getName(void) { return m_strName; }; + + /// Set company name + void setName(const std::string name) { m_strName = name; }; + + /// Get address object + CMDF_Address *getAddressObj(void) { return &m_address; }; + /*! Get a phone object from it's index @param index Index of phone object to get. @@ -2882,7 +2956,7 @@ class CMDF : public CMDF_Object { void setModuleName(std::string &str) { m_name = str; }; /*! - Get module version + Get module model @return Return string with module version. */ std::string getModuleModel(void) { return m_strModule_Model; }; @@ -2891,7 +2965,7 @@ class CMDF : public CMDF_Object { Set module model @Param Module model as string */ - void setModuleModel(std::string &str) { m_name = str; }; + void setModuleModel(std::string &str) { m_strModule_Model = str; }; /*! Get module change date @@ -2901,10 +2975,9 @@ class CMDF : public CMDF_Object { /*! Set module change date - @param str Module change date as ISO date formatted string + @pparam str Module change date as ISO date formatted string */ - void setModuleModel(std::string &str) { m_strModule_changeDate = str; }; - + void setModuleChangeDate(std::string &str) { m_strModule_changeDate = str; }; /*! Get module version @@ -2916,7 +2989,7 @@ class CMDF : public CMDF_Object { Set module version @param str Module version on stringt form */ - std::string setModuleVersion(std::string &str) { m_strModule_Model = str; }; + void setModuleVersion(std::string &str) { m_strModule_Version = str; }; /*! Get module buffer size @@ -2985,7 +3058,7 @@ class CMDF : public CMDF_Object { /*! Get the module description map */ - std::map *getModuleDescriptionMap(void) { return &m_mapDescription; }; + std::map *getDescriptionMap(void) { return &m_mapDescription; }; /*! Get Module info url in selected language. @@ -3004,7 +3077,7 @@ class CMDF : public CMDF_Object { /*! Get the module description map */ - std::map *getModuleHelpUrlMap(void) { return &m_mapInfoURL; }; + std::map *getHelpUrlMap(void) { return &m_mapInfoURL; };