svd2cpp/Src/XmlParser.hpp

41 lines
1.3 KiB
C++
Raw Permalink Normal View History

#ifndef XML_PARSER
#define XML_PARSER
#include <tinyxml2.h>
#include <string>
#include <optional>
#include <memory>
#include <DeviceInfo.hpp>
#include <vector>
#include <Peripheral.hpp>
struct XmlParser{
XmlParser(const std::string& inputFile);
std::optional<std::string> isError() const;
void parseXml();
inline const DeviceInfo& getDeviceInfo() const{
2019-11-22 11:57:17 +00:00
return deviceInfo;
}
inline const std::vector<Peripheral>& getPeripherals() const{
2019-11-22 11:57:17 +00:00
return peripherals;
}
private:
// tinyxml2::XMLElement* getDevice
void setDeviceInfoAttrib(tinyxml2::XMLElement* deviceRoot, const char* name, std::string &field) const;
void setDeviceInfoAttrib(tinyxml2::XMLElement* deviceRoot, const char* name, unsigned int &field) const;
void setDeviceInfoAttrib(tinyxml2::XMLElement* deviceRoot, const char* name, EAccess &field) const;
Peripheral parsePeripheral(tinyxml2::XMLElement* peripheralRoot) const;
AddressBlock parseAddressBlock(tinyxml2::XMLElement* addressBlockRoot) const;
Register parseRegister(tinyxml2::XMLElement* registerRoot) const;
Field parseField(tinyxml2::XMLElement* fieldRoot) const;
private:
tinyxml2::XMLDocument xmlDocument;
static const inline std::string noValue = "Not found";
DeviceInfo deviceInfo;
std::vector<Peripheral> peripherals;
};
2019-11-14 09:34:46 +00:00
#endif