build: split source and header directories

Split the headers and source to simplify the install_header
directive such that we no longer need to specify cpp files
to exclude in the install_header call.

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Iac4c38f95e690aa8ef8ecf87b032f55a1a31409c
diff --git a/src/exception.cpp b/src/exception.cpp
new file mode 100644
index 0000000..c13c5dd
--- /dev/null
+++ b/src/exception.cpp
@@ -0,0 +1,124 @@
+#include <sdbusplus/exception.hpp>
+
+#include <stdexcept>
+#include <utility>
+
+namespace sdbusplus
+{
+namespace exception
+{
+
+SdBusError::SdBusError(int error, const char* prefix, SdBusInterface* intf) :
+    error(SD_BUS_ERROR_NULL), intf(intf)
+{
+    // We can't check the output of intf->sd_bus_error_set_errno() because
+    // it returns the input errorcode. We don't want to try and guess
+    // possible error statuses. Instead, check to see if the error was
+    // constructed to determine success.
+    intf->sd_bus_error_set_errno(&this->error, error);
+    if (!intf->sd_bus_error_is_set(&this->error))
+    {
+        throw std::runtime_error("Failed to create SdBusError");
+    }
+
+    populateMessage(prefix);
+}
+
+SdBusError::SdBusError(sd_bus_error* error, const char* prefix,
+                       SdBusInterface* intf) :
+    error(*error),
+    intf(intf)
+{
+    // We own the error so remove the caller's reference
+    *error = SD_BUS_ERROR_NULL;
+
+    populateMessage(prefix);
+}
+
+SdBusError::SdBusError(SdBusError&& other) : error(SD_BUS_ERROR_NULL)
+{
+    move(std::move(other));
+}
+
+SdBusError& SdBusError::operator=(SdBusError&& other)
+{
+    if (this != &other)
+    {
+        move(std::move(other));
+    }
+    return *this;
+}
+
+SdBusError::~SdBusError()
+{
+    intf->sd_bus_error_free(&error);
+}
+
+const char* SdBusError::name() const noexcept
+{
+    return error.name;
+}
+
+const char* SdBusError::description() const noexcept
+{
+    return error.message;
+}
+
+const char* SdBusError::what() const noexcept
+{
+    return full_message.c_str();
+}
+
+int SdBusError::get_errno() const noexcept
+{
+    return intf->sd_bus_error_get_errno(&this->error);
+}
+
+const sd_bus_error* SdBusError::get_error() const noexcept
+{
+    return &error;
+}
+
+void SdBusError::populateMessage(const char* prefix)
+{
+    full_message = prefix;
+    if (error.name)
+    {
+        full_message += ": ";
+        full_message += error.name;
+    }
+    if (error.message)
+    {
+        full_message += ": ";
+        full_message += error.message;
+    }
+}
+
+void SdBusError::move(SdBusError&& other)
+{
+    intf = std::move(other.intf);
+
+    intf->sd_bus_error_free(&error);
+    error = other.error;
+    other.error = SD_BUS_ERROR_NULL;
+
+    full_message = std::move(other.full_message);
+}
+
+const char* InvalidEnumString::name() const noexcept
+{
+    return errName;
+}
+
+const char* InvalidEnumString::description() const noexcept
+{
+    return errDesc;
+}
+
+const char* InvalidEnumString::what() const noexcept
+{
+    return errWhat;
+}
+
+} // namespace exception
+} // namespace sdbusplus
diff --git a/src/sdbus.cpp b/src/sdbus.cpp
new file mode 100644
index 0000000..cc253e7
--- /dev/null
+++ b/src/sdbus.cpp
@@ -0,0 +1,6 @@
+#include <sdbusplus/sdbus.hpp>
+
+namespace sdbusplus
+{
+SdBusImpl sdbus_impl;
+}
diff --git a/src/server/transaction.cpp b/src/server/transaction.cpp
new file mode 100644
index 0000000..2a9697f
--- /dev/null
+++ b/src/server/transaction.cpp
@@ -0,0 +1,18 @@
+#include "sdbusplus/server/transaction.hpp"
+
+namespace sdbusplus
+{
+namespace server
+{
+namespace transaction
+{
+namespace details
+{
+
+// Transaction Id
+thread_local uint64_t id = 0;
+
+} // namespace details
+} // namespace transaction
+} // namespace server
+} // namespace sdbusplus