Initialize Tizen 2.3
[framework/web/wrt-plugins-common.git] / src_mobile / Commons / RegexUtils.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_UTILS_H_
17 #define WRTDEVICEAPIS_COMMONS_REGEX_UTILS_H_
18
19 #include <string>
20
21 namespace WrtDeviceApis {
22 namespace Commons {
23 /**
24  * Adds ^ character at the beginning in proper way
25  * @param value Regexp pattern
26  * @return Proper regular expression's pattern.
27  */
28 std::string addStartPositionMark(const std::string &value);
29
30 /**
31  * Adds $ character at the end in proper way
32  * @param value Regexp pattern
33  * @return Proper regular expression's pattern.
34  */
35 std::string addEndPositionMark(const std::string &value);
36
37 /**
38  * Adds ^ character at the beginning and $ the end in proper way
39  * @param value Regexp pattern
40  * @return Proper regular expression's pattern.
41  */
42 std::string addStartAndEndPositionMark(const std::string &value);
43
44 /**
45  * Converts typical string with wildcard '%' to proper perl-like regular
46  * expression's pattern.
47  * @param str String that came from JS.
48  * @return Proper regular expression's pattern.
49  * @remarks Calling it twice will (probably?) cause double escaping.
50  */
51 std::string preparePercent(const std::string& str);
52
53 /**
54  * Converts typical string with wildcard '*' to proper perl-like regular
55  * expression's pattern.
56  * @param str String that came from JS.
57  * @return Proper regular expression's pattern.
58  * @remarks Calling it twice will (probably?) cause double escaping.
59  */
60 std::string prepareAsterisk(const std::string& str);
61
62 /**
63  * Escapes regex special characters.
64  * @param str String to escape.
65  * @return String with regex special characters escaped.
66  */
67 std::string escape(const std::string& str);
68 }
69 } // WrtDeviceApisCommon
70
71 #endif // WRTDEVICEAPIS_COMMONS_REGEX_UTILS_H_