66#include < exception>
77#include < map>
88
9+ #include " cpp_can_parser_export.h"
910#include " CANFrame.h"
1011#include " CANDatabaseException.h"
1112
2324 * If the database was parsed from a file, the filename() method can be used to
2425 * retrieve the name of the source file.
2526 */
26- class CANDatabase {
27+ class CPP_CAN_PARSER_EXPORT CANDatabase {
28+ public:
29+ /* *
30+ * @brief A parsing warning and its location
31+ */
32+ struct parsing_warning {
33+ unsigned long long line;
34+ std::string description;
35+ };
36+
2737public:
2838 /* *
2939 * @brief Parse a CANDatabase from the given source file.
3040 * @param filename Path to the file to parse
41+ * @param warnings (Optional) Filled with all the warnings found during the parsing
3142 * @throw CANDatabaseException if the parsing failed
3243 */
33- static CANDatabase fromFile (const std::string& filename);
44+ static CANDatabase fromFile (
45+ const std::string& filename, std::vector<parsing_warning>* warnings = nullptr );
3446
3547 /* *
3648 * @brief Construct a CANDatabase object from a database described by src_string
3749 * @param src_string Source string to parse
50+ * @param warnings (Optional) Filled with all the warnings found during the parsing
3851 * @throw CANDatabaseException if the parsing failed
3952 */
40- static CANDatabase fromString (const std::string& src_string);
53+ static CANDatabase fromString (
54+ const std::string& src_string, std::vector<parsing_warning>* warnings = nullptr );
4155
4256public:
4357 struct IDKey {
@@ -60,7 +74,7 @@ class CANDatabase {
6074 /* *
6175 * @brief Creates a CANDatabase object with no source file
6276 */
63- CANDatabase () = default ;
77+ CANDatabase ();
6478
6579 /* *
6680 * @brief Creates a CANDatabase object that has been constructed from a file
@@ -72,23 +86,24 @@ class CANDatabase {
7286 * Creates a copy of the database: the individual frames are deep copied so there is no
7387 * shared memory betwwen the two databases.
7488 */
75- CANDatabase (const CANDatabase&) = default ;
89+ CANDatabase (const CANDatabase&);
7690
7791 /* *
7892 * @brief Makes a copy of the given database
7993 */
80- CANDatabase& operator =(const CANDatabase&) = default ;
94+ CANDatabase& operator =(const CANDatabase&);
8195
8296 /* *
8397 * @brief Moves a CANDatabase object. The CANFrame objects are NOT deep copied.
8498 */
85- CANDatabase (CANDatabase&&) = default ;
99+ CANDatabase (CANDatabase&&);
86100
87101 /* *
88- * @see CANDatabase(const CANDatabase&&)
102+ * @see CANDatabase(CANDatabase&&)
89103 */
90- CANDatabase& operator =(CANDatabase&&) = default ;
104+ CANDatabase& operator =(CANDatabase&&);
91105
106+ ~CANDatabase ();
92107public:
93108 /* *
94109 * @brief Get the frame with the given frame name
@@ -182,11 +197,8 @@ class CANDatabase {
182197 void removeFrame (const std::string& name);
183198
184199private:
185- std::string filename_;
186- container_type map_; // Index by CAN ID
187-
188- std::map<unsigned long long , IDKey> intKeyIndex_;
189- std::map<std::string, IDKey> strKeyIndex_;
200+ class CANDatabaseImpl ;
201+ CANDatabaseImpl* impl;
190202};
191203
192204#endif
0 commit comments