Initialize Tizen 2.3
[framework/web/wrt-plugins-common.git] / src_mobile / 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 const unsigned int VALIDATE_MATCH_CASELESS = 0x0001;     //use when you want to
24                                                          // make caseless match
25 const unsigned int VALIDATE_MATCH_FULL = 0x0002;         //use when you want
26                                                          // supplied text
27                                                          // matches a supplied
28                                                          // pattern exactly
29 const std::string LOWER_P = "p";
30 const std::string UPPER_P = "P";
31
32 /**
33  * Validates value against pattern
34  * @param pattern Regexp pattern
35  * @param value String to validate
36  * @param options Modifiers for a match.
37  * @return True when value is matched against pattern
38  */
39 bool validate(const std::string &pattern,
40               const std::string &value,
41               unsigned int options = 0);
42
43 /**
44  * Filter value against pattern(Any character except "0-9+#*Pp" will be removed
45  * from value)
46  * @param pattern Regexp pattern
47  * @param value String to be filtered
48  * @return filtered value
49  */
50 std::string filter(const std::string &pattern,
51                    const std::string &value);
52
53 /**
54  * Replace character "p" in value by "P"
55  * @param value String to be replaced
56  * @return replaced value
57  */
58 std::string toUpper(const std::string &value);
59 }
60 } // WrtDeviceApisCommon
61
62 #endif // WRTDEVICEAPIS_COMMONS_REGEX_H_