Merge "Refactor source files into separate libraries"
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2abb379..1dd95a3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -64,6 +64,21 @@
 # we don't need filename tracking, and we prefer to use header-only Boost
 add_definitions(-DBOOST_SPIRIT_X3_NO_FILESYSTEM)
 
+add_library(path STATIC
+    src/ast_path.cpp
+    )
+target_link_libraries(path Boost::boost)
+
+add_library(ast_values STATIC
+    src/ast_values.cpp
+    )
+target_link_libraries(ast_values Boost::boost)
+
+add_library(utils STATIC
+    src/utils.cpp
+    )
+target_link_libraries(utils path Boost::boost)
+
 add_library(schemas STATIC
     src/static_schema.cpp
     src/schema.cpp
@@ -79,7 +94,7 @@
     src/sysrepo_access.cpp
     )
 
-target_link_libraries(sysrepoaccess datastoreaccess ${SYSREPO_LIBRARIES})
+target_link_libraries(sysrepoaccess datastoreaccess ast_values ${SYSREPO_LIBRARIES})
 link_directories(${SYSREPO_LIBRARY_DIRS})
 target_include_directories(sysrepoaccess SYSTEM PRIVATE ${SYSREPO_INCLUDE_DIRS})
 
@@ -88,7 +103,7 @@
     src/netconf_access.cpp
     )
 
-target_link_libraries(netconfaccess datastoreaccess ${LIBNETCONF2_LIBRARIES})
+target_link_libraries(netconfaccess datastoreaccess ast_values ${LIBNETCONF2_LIBRARIES})
 link_directories(${LIBNETCONF2_LIBRARY_DIRS})
 target_include_directories(netconfaccess SYSTEM PRIVATE ${LIBNETCONF2_INCLUDE_DIRS})
 
@@ -103,13 +118,11 @@
 add_library(parser STATIC
     src/parser.cpp
     src/ast_commands.cpp
-    src/ast_path.cpp
-    src/utils.cpp
     src/parser_context.cpp
     src/interpreter.cpp
     src/ast_handlers.cpp
     )
-target_link_libraries(parser schemas)
+target_link_libraries(parser schemas utils ast_values)
 
 
 add_library(sysreposubscription STATIC
@@ -262,6 +275,7 @@
     cli_test(list_manipulation)
     cli_test(parser_methods)
     cli_test(path_utils)
+    target_link_libraries(test_path_utils path)
 
     setup_datastore_tests()
     datastore_test(setting_values ${CMAKE_CURRENT_SOURCE_DIR}/example-schema.yang)
diff --git a/src/ast_values.cpp b/src/ast_values.cpp
new file mode 100644
index 0000000..b8ca68d
--- /dev/null
+++ b/src/ast_values.cpp
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2019 CESNET, https://photonics.cesnet.cz/
+ *
+ * Written by Václav Kubernát <kubervac@fit.cvut.cz>
+ *
+*/
+#include "ast_values.hpp"
+
+enum_::enum_() = default;
+
+enum_::enum_(const std::string& value)
+    : m_value(value)
+{
+}
+
+identityRef_::identityRef_() = default;
+
+identityRef_::identityRef_(const std::string& value)
+    : m_value(value)
+{
+}
+
+identityRef_::identityRef_(const std::string& module, const std::string& value)
+    : m_prefix(module_{module})
+    , m_value(value)
+{
+}
+
+binary_::binary_() = default;
+
+binary_::binary_(const std::string& value)
+    : m_value(value)
+{
+}
+
+bool identityRef_::operator==(const identityRef_& b) const
+{
+    return this->m_prefix == b.m_prefix && this->m_value == b.m_value;
+}
+
+bool binary_::operator==(const binary_& b) const
+{
+    return this->m_value == b.m_value;
+}
+
+bool enum_::operator==(const enum_& b) const
+{
+    return this->m_value == b.m_value;
+}
+