summaryrefslogtreecommitdiff
path: root/src/Commons/Regex.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/Commons/Regex.h')
-rw-r--r--src/Commons/Regex.h62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/Commons/Regex.h b/src/Commons/Regex.h
new file mode 100644
index 0000000..f6c046b
--- /dev/null
+++ b/src/Commons/Regex.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef WRTDEVICEAPIS_COMMONS_REGEX_H_
+#define WRTDEVICEAPIS_COMMONS_REGEX_H_
+
+#include <string>
+
+namespace WrtDeviceApis {
+namespace Commons {
+const unsigned int VALIDATE_MATCH_CASELESS = 0x0001; //use when you want to
+ // make caseless match
+const unsigned int VALIDATE_MATCH_FULL = 0x0002; //use when you want
+ // supplied text
+ // matches a supplied
+ // pattern exactly
+const std::string LOWER_P = "p";
+const std::string UPPER_P = "P";
+
+/**
+ * Validates value against pattern
+ * @param pattern Regexp pattern
+ * @param value String to validate
+ * @param options Modifiers for a match.
+ * @return True when value is matched against pattern
+ */
+bool validate(const std::string &pattern,
+ const std::string &value,
+ unsigned int options = 0);
+
+/**
+ * Filter value against pattern(Any character except "0-9+#*Pp" will be removed
+ * from value)
+ * @param pattern Regexp pattern
+ * @param value String to be filtered
+ * @return filtered value
+ */
+std::string filter(const std::string &pattern,
+ const std::string &value);
+
+/**
+ * Replace character "p" in value by "P"
+ * @param value String to be replaced
+ * @return replaced value
+ */
+std::string toUpper(const std::string &value);
+}
+} // WrtDeviceApisCommon
+
+#endif // WRTDEVICEAPIS_COMMONS_REGEX_H_