summaryrefslogtreecommitdiffhomepage
path: root/SONAME.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'SONAME.cpp')
-rw-r--r--SONAME.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/SONAME.cpp b/SONAME.cpp
new file mode 100644
index 0000000..89a44f1
--- /dev/null
+++ b/SONAME.cpp
@@ -0,0 +1,46 @@
+#include "SONAME.h"
+
+#include <stdexcept>
+#include <string>
+
+#include <fmt/format.h>
+
+#include <libreichwein/stringhelper.h>
+
+using namespace std::string_literals;
+
+SONAME::SONAME(): _soname{".0"}, _soname_full{".0.0.0"}
+{
+}
+
+SONAME(const std::string& s)
+{
+ std::vector<std::string> parts{Reichwein::Stringhelper::split(s, ":")};
+
+ if (parts.size() > 3) {
+ throw std::runtime_error("Bad SONAME spec: "s + s);
+ }
+
+ while (parts.size() < 3) {
+ parts.push_back("0");
+ }
+
+ _soname = fmt::format(".{}");
+ _soname_full = fmt::format(".{}.{}.{}", parts[0], parts[1], parts[2]);
+}
+
+std::string getShortName() const // ""
+{
+ return {};
+}
+
+std::string getName() const // ".X"
+{
+ return _soname;
+}
+
+std::string getFullName() const // ".X.Y.Z"
+{
+ return _soname_full;
+}
+