summaryrefslogtreecommitdiff
path: root/gentoobrowse-api/service/utils/splitEbuildProps.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gentoobrowse-api/service/utils/splitEbuildProps.cpp')
-rw-r--r--gentoobrowse-api/service/utils/splitEbuildProps.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/gentoobrowse-api/service/utils/splitEbuildProps.cpp b/gentoobrowse-api/service/utils/splitEbuildProps.cpp
new file mode 100644
index 0000000..8116742
--- /dev/null
+++ b/gentoobrowse-api/service/utils/splitEbuildProps.cpp
@@ -0,0 +1,29 @@
+#include "splitEbuildProps.h"
+#include <command.h>
+#include "dbUtils.h"
+
+namespace Gentoo {
+ namespace Utils {
+ SplitEbuildProps::SplitEbuildProps(const std::string & ce, int e, const std::string & cp, const boost::optional<Glib::ustring> & p) :
+ entityId(e),
+ colEntityName(ce),
+ colPropName(cp),
+ props(p)
+ {
+ }
+
+ void
+ SplitEbuildProps::writeSql(AdHoc::Buffer & sql)
+ {
+ sql.appendbf("(SELECT DISTINCT ?::int %s, trim(regexp_split_to_table(?, '\\s+'), '+') %s)", colEntityName, colPropName);
+ }
+
+ void
+ SplitEbuildProps::bindParams(DB::Command * c, unsigned int & offset)
+ {
+ c->bindParamI(offset++, entityId);
+ Gentoo::Utils::Database::bindOptionalsS(c, offset++, { props });
+ }
+ }
+}
+