2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 #ifndef WRTDEVICEAPIS_COMMONS_REGEX_UTILS_H_
17 #define WRTDEVICEAPIS_COMMONS_REGEX_UTILS_H_
21 namespace WrtDeviceApis {
25 * Adds ^ character at the beginning in proper way
26 * @param value Regexp pattern
27 * @return Proper regular expression's pattern.
29 std::string addStartPositionMark(const std::string &value);
32 * Adds $ character at the end in proper way
33 * @param value Regexp pattern
34 * @return Proper regular expression's pattern.
36 std::string addEndPositionMark(const std::string &value);
39 * Adds ^ character at the beginning and $ the end in proper way
40 * @param value Regexp pattern
41 * @return Proper regular expression's pattern.
43 std::string addStartAndEndPositionMark(const std::string &value);
46 * Converts typical string with wildcard '%' to proper perl-like regular
47 * expression's pattern.
48 * @param str String that came from JS.
49 * @return Proper regular expression's pattern.
50 * @remarks Calling it twice will (probably?) cause double escaping.
52 std::string preparePercent(const std::string& str);
55 * Converts typical string with wildcard '*' to proper perl-like regular
56 * expression's pattern.
57 * @param str String that came from JS.
58 * @return Proper regular expression's pattern.
59 * @remarks Calling it twice will (probably?) cause double escaping.
61 std::string prepareAsterisk(const std::string& str);
64 * Escapes regex special characters.
65 * @param str String to escape.
66 * @return String with regex special characters escaped.
68 std::string escape(const std::string& str);
71 } // WrtDeviceApisCommon
73 #endif // WRTDEVICEAPIS_COMMONS_REGEX_UTILS_H_