svd2cpp/Src/XmlParser.hpp

35 lines
1.1 KiB
C++
Raw Normal View History

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