-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add cMetadata classe to result format library
Signed-off-by: romanodanilo <[email protected]>
- Loading branch information
1 parent
c2ab2bd
commit a934870
Showing
6 changed files
with
193 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/** | ||
* Copyright 2023 CARIAD SE. | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla | ||
* Public License, v. 2.0. If a copy of the MPL was not distributed | ||
* with this file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
#ifndef cMetadata_h__ | ||
#define cMetadata_h__ | ||
|
||
#include "string" | ||
#include "../xml/util_xerces.h" | ||
|
||
class cChecker; | ||
|
||
|
||
class cMetadata | ||
{ | ||
|
||
public: | ||
static const XMLCh *TAG_NAME; | ||
static const XMLCh *ATTR_KEY; | ||
static const XMLCh *ATTR_VALUE; | ||
static const XMLCh *ATTR_DESCRIPTION; | ||
|
||
/* | ||
* Creates a new instance of cMetadata | ||
* \param m_Key: metadata key | ||
* \param m_Value: metadata value | ||
* \param m_Description: metadata description | ||
* \param description: Additional description | ||
*/ | ||
cMetadata(const std::string& input_key, const std::string& input_value,const std::string& input_description):m_Key(input_key), m_Value(input_value), m_Description(input_description) | ||
{ | ||
} | ||
|
||
// Serialize this information | ||
virtual XERCES_CPP_NAMESPACE::DOMElement *WriteXML(XERCES_CPP_NAMESPACE::DOMDocument *p_resultDocument); | ||
|
||
// Unserialize this information | ||
static cMetadata *ParseFromXML(XERCES_CPP_NAMESPACE::DOMNode *pXMLNode, | ||
XERCES_CPP_NAMESPACE::DOMElement *pXMLElement, cChecker *checker); | ||
|
||
|
||
// Assigns an issue to a checker | ||
void AssignChecker(cChecker *checkerToAssign); | ||
|
||
// Returns the Key | ||
std::string GetKey() const; | ||
// Returns the Value | ||
std::string GetValue() const; | ||
// Returns the Description | ||
std::string GetDescription() const; | ||
|
||
|
||
protected: | ||
std::string m_Key, m_Value, m_Description; | ||
cChecker *m_Checker; | ||
|
||
private: | ||
cMetadata(); | ||
cMetadata(const cMetadata &); | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Copyright 2023 CARIAD SE. | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla | ||
* Public License, v. 2.0. If a copy of the MPL was not distributed | ||
* with this file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
*/ | ||
#include "common/result_format/c_metadata.h" | ||
|
||
XERCES_CPP_NAMESPACE_USE | ||
|
||
const XMLCh *cMetadata::TAG_NAME = CONST_XMLCH("Metadata"); | ||
const XMLCh *cMetadata::ATTR_KEY = CONST_XMLCH("key"); | ||
const XMLCh *cMetadata::ATTR_VALUE = CONST_XMLCH("value"); | ||
const XMLCh *cMetadata::ATTR_DESCRIPTION = CONST_XMLCH("description"); | ||
|
||
DOMElement *cMetadata::WriteXML(DOMDocument *p_resultDocument) | ||
{ | ||
|
||
DOMElement *p_DataElement = p_resultDocument->createElement(TAG_NAME); | ||
XMLCh *pKey = XMLString::transcode(m_Key.c_str()); | ||
XMLCh *pValue = XMLString::transcode(m_Value.c_str()); | ||
XMLCh *pDescription = XMLString::transcode(m_Description.c_str()); | ||
p_DataElement->setAttribute(ATTR_KEY, pKey); | ||
p_DataElement->setAttribute(ATTR_VALUE, pValue); | ||
p_DataElement->setAttribute(ATTR_DESCRIPTION, pDescription); | ||
|
||
XMLString::release(&pKey); | ||
XMLString::release(&pValue); | ||
XMLString::release(&pDescription); | ||
|
||
return p_DataElement; | ||
} | ||
|
||
cMetadata *cMetadata::ParseFromXML(DOMNode *, DOMElement *pXMLElement, cChecker *checker) | ||
{ | ||
std::string strKey = XMLString::transcode(pXMLElement->getAttribute(ATTR_KEY)); | ||
std::string strValue = XMLString::transcode(pXMLElement->getAttribute(ATTR_VALUE)); | ||
std::string strDescription = XMLString::transcode(pXMLElement->getAttribute(ATTR_DESCRIPTION)); | ||
|
||
cMetadata *result = new cMetadata(strKey, strValue, strDescription); | ||
result->AssignChecker(checker); | ||
|
||
return result; | ||
} | ||
|
||
// Returns the key | ||
std::string cMetadata::GetKey() const | ||
{ | ||
return m_Key; | ||
} | ||
|
||
// Returns the value | ||
std::string cMetadata::GetValue() const | ||
{ | ||
return m_Value; | ||
} | ||
|
||
// Returns the description | ||
std::string cMetadata::GetDescription() const | ||
{ | ||
return m_Description; | ||
} | ||
void cMetadata::AssignChecker(cChecker *checkerToAssign) | ||
{ | ||
m_Checker = checkerToAssign; | ||
} |