diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/trygvis/kicad.h | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/include/trygvis/kicad.h b/include/trygvis/kicad.h new file mode 100644 index 0000000..4cff944 --- /dev/null +++ b/include/trygvis/kicad.h @@ -0,0 +1,80 @@ +#pragma once + +#include <string> +#include <vector> +#include <stdexcept> +#include <experimental/optional> + +namespace trygvis { +namespace kicad { + +template<typename T> +using opt = std::experimental::optional<T>; + +class component { +public: + std::string ref; + std::string value; + + component(const std::string &ref, const std::string &value) : ref(ref), value(value) { } +}; + +struct pin { + int num; + std::string name; + std::string type; +}; + +struct part { + std::vector<pin> pins; +}; + +class node { +public: + std::string ref; + int pin; + + node(const std::string &ref, int pin) : ref(ref), pin(pin) { } +}; + +class net { +public: + int code; + std::string name; + std::vector<node> nodes; + + net(int code, const std::string &name, const std::vector<node> &nodes) : code(code), name(name), nodes(nodes) { } +}; + +struct netlist { + std::vector<component> components; + std::vector<part> parts; + std::vector<net> nets; + + opt<const component *> find_component(std::string ref) const; +}; + +class kicad_parse_exception : public std::runtime_error { +public: + explicit kicad_parse_exception(const std::vector<std::string> &messages) : + runtime_error("Parse error"), messages(messages) { } + + const std::vector<std::string> messages; +}; + +class kicad_net_loader { +public: + kicad_net_loader(); + + virtual ~kicad_net_loader(); + + netlist load(std::string path); + + void setDebug(bool debug); + +private: + bool debug_; +}; + +} // namespace kicad +} // namespace trygvis |