tizen beta release
[framework/web/wrt-plugins-common.git] / src / Commons / Regex.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *    Licensed under the Apache License, Version 2.0 (the "License");
5  *    you may not use this file except in compliance with the License.
6  *    You may obtain a copy of the License at
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *    Unless required by applicable law or agreed to in writing, software
11  *    distributed under the License is distributed on an "AS IS" BASIS,
12  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *    See the License for the specific language governing permissions and
14  *    limitations under the License.
15  */
16 #ifndef WRTDEVICEAPIS_COMMONS_REGEX_H_
17 #define WRTDEVICEAPIS_COMMONS_REGEX_H_
18
19 #include <string>
20
21 namespace WrtDeviceApis {
22 namespace Commons {
23
24 const unsigned int VALIDATE_MATCH_CASELESS = 0x0001;     //use when you want to make caseless match
25 const unsigned int VALIDATE_MATCH_FULL = 0x0002;         //use when you want supplied text matches a supplied pattern exactly
26 const std::string LOWER_P = "p";
27 const std::string UPPER_P = "P";
28
29 /**
30  * Validates value against pattern
31  * @param pattern Regexp pattern
32  * @param value String to validate
33  * @param options Modifiers for a match.
34  * @return True when value is matched against pattern
35  */
36 bool validate(const std::string &pattern,
37         const std::string &value,
38         unsigned int options = 0);
39
40 /**
41  * Filter value against pattern(Any character except "0-9+#*Pp" will be removed from value)
42  * @param pattern Regexp pattern
43  * @param value String to be filtered
44  * @return filtered value
45  */
46 std::string filter(const std::string &pattern,
47         const std::string &value);
48
49 /**
50  * Replace character "p" in value by "P"
51  * @param value String to be replaced
52  * @return replaced value
53  */
54 std::string toUpper(const std::string &value);
55
56 }
57 } // WrtDeviceApisCommon
58
59 #endif // WRTDEVICEAPIS_COMMONS_REGEX_H_