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 {
24 * Adds ^ character at the beginning in proper way
25 * @param value Regexp pattern
26 * @return Proper regular expression's pattern.
28 std::string addStartPositionMark(const std::string &value);
31 * Adds $ character at the end in proper way
32 * @param value Regexp pattern
33 * @return Proper regular expression's pattern.
35 std::string addEndPositionMark(const std::string &value);
38 * Adds ^ character at the beginning and $ the end in proper way
39 * @param value Regexp pattern
40 * @return Proper regular expression's pattern.
42 std::string addStartAndEndPositionMark(const std::string &value);
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.
51 std::string preparePercent(const std::string& str);
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.
60 std::string prepareAsterisk(const std::string& str);
63 * Escapes regex special characters.
64 * @param str String to escape.
65 * @return String with regex special characters escaped.
67 std::string escape(const std::string& str);
69 } // WrtDeviceApisCommon
71 #endif // WRTDEVICEAPIS_COMMONS_REGEX_UTILS_H_