Fixed problem in DeviceSettings::strParam, returned wrong string
[avr-sim.git] / src / DeviceSettings.h
blobe24d5ff6099d7c8fd66d85b5596d341fd18953c7
1 #ifndef AVR_DEVICESETTINGS_H
2 #define AVR_DEVICESETTINGS_H
4 #include "Exception.h"
5 #include <string>
7 struct _xmlNode;
9 namespace avr {
11 class ParseException : public util::Exception {
12 public:
13 ParseException() : Exception("Parse Exception") {}
14 ParseException(const char * msg) : Exception(msg) {}
15 ParseException(const std::string & msg) : Exception(msg) {}
18 class Device;
19 class XmlHandle;
21 /**
22 * @author Tom Haber
23 * @date Apr 26, 2008
24 * @brief Helper for reading Hardware modules from XML
26 * The HardwareSettings class allows reading Hardware settings
27 * from the xml file without exposing the xml related
28 * bits.
30 class HardwareSettings {
31 public:
32 HardwareSettings(XmlHandle & doc, _xmlNode *node);
34 public:
35 int intParam(const char *name, int base = 10) const;
36 int intParamDef(const char *name, int def = 0, int base = 10) const;
37 std::string strParam(const char *name) const;
39 public:
40 bool getBinding(std::string & name, std::string & binding);
42 private:
43 _xmlNode *findParam(const char *name, bool required = true) const;
45 private:
46 XmlHandle & doc;
47 _xmlNode *node;
48 _xmlNode *reg;
49 _xmlNode *params;
52 /**
53 * @author Tom Haber
54 * @date Apr 21, 2008
55 * @brief Reading device settings from xml files
57 * This class allows reading device settings from xml files.
59 class DeviceSettings {
60 public:
61 static void listAll(unsigned int lineLength = 80);
62 static void load(Device *dev, const char *devicename);
64 private:
65 static void parseMemory(Device *dev, _xmlNode *memory);
66 static void parseRegisters(Device *dev, _xmlNode *registers);
67 static void parseInterrupts(Device *dev, _xmlNode *interrupts);
68 static void parseHardware(Device *dev, XmlHandle & doc, _xmlNode *hardware);
69 static void parsePackages(Device *dev, const char *pkgname, _xmlNode *hardware);
70 static void parsePackage(Device *dev, _xmlNode *hardware);
74 #endif /*AVR_DEVICESETTINGS_H*/