]> git.tdb.fi Git - builder.git/blobdiff - source/pattern.cpp
Have Architecture provide pattern lists for library and executable filenames
[builder.git] / source / pattern.cpp
diff --git a/source/pattern.cpp b/source/pattern.cpp
new file mode 100644 (file)
index 0000000..e87981f
--- /dev/null
@@ -0,0 +1,18 @@
+#include <stdexcept>
+#include "pattern.h"
+
+using namespace std;
+
+Pattern::Pattern(const string &pat)
+{
+       string::size_type percent = pat.find('%');
+       if(percent==string::npos)
+               throw invalid_argument("No percent sign in pattern");
+       prefix = pat.substr(0, percent);
+       suffix = pat.substr(percent+1);
+}
+
+string Pattern::apply(const string &body) const
+{
+       return prefix+body+suffix;
+}