| 1 | // |
|---|---|
| 2 | // RegularExpression.cpp |
| 3 | // |
| 4 | // Library: MongoDB |
| 5 | // Package: MongoDB |
| 6 | // Module: RegularExpression |
| 7 | // |
| 8 | // Copyright (c) 2012, Applied Informatics Software Engineering GmbH. |
| 9 | // and Contributors. |
| 10 | // |
| 11 | // SPDX-License-Identifier: BSL-1.0 |
| 12 | // |
| 13 | |
| 14 | |
| 15 | #include "Poco/MongoDB/RegularExpression.h" |
| 16 | #include <sstream> |
| 17 | |
| 18 | |
| 19 | namespace Poco { |
| 20 | namespace MongoDB { |
| 21 | |
| 22 | |
| 23 | RegularExpression::RegularExpression() |
| 24 | { |
| 25 | } |
| 26 | |
| 27 | |
| 28 | RegularExpression::RegularExpression(const std::string& pattern, const std::string& options): |
| 29 | _pattern(pattern), |
| 30 | _options(options) |
| 31 | { |
| 32 | } |
| 33 | |
| 34 | |
| 35 | RegularExpression::~RegularExpression() |
| 36 | { |
| 37 | } |
| 38 | |
| 39 | |
| 40 | SharedPtr<Poco::RegularExpression> RegularExpression::createRE() const |
| 41 | { |
| 42 | int options = 0; |
| 43 | for (std::string::const_iterator optIt = _options.begin(); optIt != _options.end(); ++optIt) |
| 44 | { |
| 45 | switch (*optIt) |
| 46 | { |
| 47 | case 'i': // Case Insensitive |
| 48 | options |= Poco::RegularExpression::RE_CASELESS; |
| 49 | break; |
| 50 | case 'm': // Multiline matching |
| 51 | options |= Poco::RegularExpression::RE_MULTILINE; |
| 52 | break; |
| 53 | case 'x': // Verbose mode |
| 54 | //No equivalent in Poco |
| 55 | break; |
| 56 | case 'l': // \w \W Locale dependent |
| 57 | //No equivalent in Poco |
| 58 | break; |
| 59 | case 's': // Dotall mode |
| 60 | options |= Poco::RegularExpression::RE_DOTALL; |
| 61 | break; |
| 62 | case 'u': // \w \W Unicode |
| 63 | //No equivalent in Poco |
| 64 | break; |
| 65 | } |
| 66 | } |
| 67 | return new Poco::RegularExpression(_pattern, options); |
| 68 | } |
| 69 | |
| 70 | |
| 71 | } } // namespace Poco::MongoDB |
| 72 |