summaryrefslogtreecommitdiff
path: root/rld-config.h
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2014-08-01 16:44:32 +1000
committerChris Johns <chrisj@rtems.org>2014-08-01 16:48:09 +1000
commit482ca38073a878814640089086c0ba262e80e4cd (patch)
treeabbb44345656565ac3e302770155743f205b955c /rld-config.h
parent742866c4ac6e2f674971225d26052b9af22bd6b3 (diff)
Add initial support for the RTEM Trace Linker.
The RTEMS Trace Linker or rtems-rld creates an RTEMS executable with trace support built in without any changes the existing code. This commit is an initial starting point with function signatures being read from INI files.
Diffstat (limited to 'rld-config.h')
-rw-r--r--rld-config.h136
1 files changed, 136 insertions, 0 deletions
diff --git a/rld-config.h b/rld-config.h
new file mode 100644
index 0000000..fe622e4
--- /dev/null
+++ b/rld-config.h
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2014, Chris Johns <chrisj@rtems.org>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+/**
+ * @file
+ *
+ * @ingroup rtems_rld
+ *
+ * @brief INI Configuration reader.
+ *
+ */
+
+#if !defined (_RLD_CONFIG_H_)
+#define _RLD_CONFIG_H_
+
+#include <string>
+#include <list>
+#include <vector>
+
+namespace rld
+{
+ namespace config
+ {
+ /**
+ * The configuration item. This is a data component of a record contained
+ * in a section.
+ */
+ struct item
+ {
+ std::string text; /**< The text as read from the configuration. */
+
+ /**
+ * Construct an item.
+ */
+ item (const std::string& text);
+ item (const char* text);
+ };
+
+ /**
+ * Configuration item container.
+ */
+ typedef std::vector < item > items;
+
+ /**
+ * Configuration record is a line in a section. There can be multiple
+ * records with the same key in a section. Keys are specific to a section.
+ */
+ struct record
+ {
+ std::string name; //< Name of the record.
+ items items; //< The record's items.
+ };
+
+ /**
+ * Configuration record container.
+ */
+ typedef std::list < record > records;
+
+ /**
+ * Configuration section. A section contains a number of records and the
+ * records contain [1..n] items.
+ */
+ struct section
+ {
+ std::string name; //< Name of the section.
+ records recs; //< The section's records.
+
+ /**
+ * Find a record and throw an error if not found.
+ */
+ const record& get_record (const std::string& name) const;
+ };
+
+ /**
+ * Configuration section container.
+ */
+ typedef std::list < section > sections;
+
+ /**
+ * Container of configuration file paths loaded.
+ */
+ typedef std::vector < std::string > paths;
+
+ /**
+ * The configuration.
+ */
+ class config
+ {
+ public:
+ /**
+ * Construct an empty configuration.
+ */
+ config();
+ virtual ~config();
+
+ /**
+ * Clear the current configuration.
+ */
+ void clear ();
+
+ /**
+ * Load a configuration.
+ */
+ void load (const std::string& name);
+
+ /**
+ * Get the section and throw an error if not found.
+ */
+ const section& get_section (const std::string& name) const;
+
+ /**
+ * Get the paths of loaded configuration files.
+ */
+ const paths& get_paths () const;
+
+ private:
+
+ paths paths; /**< The path's of the loaded files. */
+ sections secs; /**< The sections loaded from configuration files */
+ };
+ }
+}
+
+#endif