50 lines
1.3 KiB
C++
50 lines
1.3 KiB
C++
#ifndef REGEX_REPLACEMENT_HDR
|
|
#define REGEX_REPLACEMENT_HDR
|
|
|
|
#include <string>
|
|
#include "concordia/common/config.hpp"
|
|
#include "concordia/concordia_exception.hpp"
|
|
#include <boost/shared_ptr.hpp>
|
|
#include <boost/regex.hpp>
|
|
#include <boost/regex/icu.hpp>
|
|
|
|
|
|
|
|
typedef boost::error_info<struct my_tag, std::string> my_tag_error_info;
|
|
|
|
/*!
|
|
Class for representing a regular expression replacement operation.
|
|
Holds regex pattern string for matching and replacement string for
|
|
replacing found matches.
|
|
|
|
*/
|
|
class RegexReplacement {
|
|
public:
|
|
/*!
|
|
Constructor.
|
|
\param patternString regex pattern to match
|
|
\param replacement string to substitute the found match
|
|
\param caseSensitive case sensitivity of the pattern
|
|
*/
|
|
RegexReplacement(std::string patternString, std::string replacement,
|
|
bool caseSensitive = true)
|
|
throw(ConcordiaException);
|
|
|
|
/*! Destructor.
|
|
*/
|
|
virtual ~RegexReplacement();
|
|
|
|
/*! Applies the operation on input string.
|
|
\param text the input string
|
|
\returns altered version of the input string
|
|
*/
|
|
std::string apply(const std::string & text);
|
|
|
|
private:
|
|
boost::u32regex _pattern;
|
|
|
|
std::string _replacement;
|
|
};
|
|
|
|
#endif
|