Skip to content

Commit

Permalink
Added som extra getter/setters
Browse files Browse the repository at this point in the history
  • Loading branch information
grodansparadis committed Oct 12, 2023
1 parent 696bbd6 commit 537f02b
Show file tree
Hide file tree
Showing 2 changed files with 113 additions and 40 deletions.
40 changes: 20 additions & 20 deletions src/vscp/common/mdf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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(
Expand All @@ -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}",
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.");
Expand Down Expand Up @@ -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.");
Expand Down
113 changes: 93 additions & 20 deletions src/vscp/common/mdf.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -182,6 +196,9 @@ class CMDF_Object {
*/
std::string getObjectTypeString(void);

virtual std::map<std::string, std::string> *getMapDescription(void) { return nullptr; };
virtual std::map<std::string, std::string> *getMapInfoUrl(void) {return nullptr; };

private:
mdf_record_type m_type;
};
Expand Down Expand Up @@ -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; };

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1670,7 +1693,7 @@ class CMDF_Item : public CMDF_Object {
std::map<std::string, std::string> *getInfoUrlMap(void) { return &m_mapInfoURL; };

private:
std::string m_name;
std::string m_value; // Item value
std::map<std::string, std::string> m_mapDescription;
std::map<std::string, std::string> m_mapInfoURL; // Url that contain extra hel information
};
Expand Down Expand Up @@ -1761,42 +1784,84 @@ 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
@return State address
*/
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;
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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; };
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -2985,7 +3058,7 @@ class CMDF : public CMDF_Object {
/*!
Get the module description map
*/
std::map<std::string, std::string> *getModuleDescriptionMap(void) { return &m_mapDescription; };
std::map<std::string, std::string> *getDescriptionMap(void) { return &m_mapDescription; };

/*!
Get Module info url in selected language.
Expand All @@ -3004,7 +3077,7 @@ class CMDF : public CMDF_Object {
/*!
Get the module description map
*/
std::map<std::string, std::string> *getModuleHelpUrlMap(void) { return &m_mapInfoURL; };
std::map<std::string, std::string> *getHelpUrlMap(void) { return &m_mapInfoURL; };



Expand Down

0 comments on commit 537f02b

Please sign in to comment.