/usr/include/ui-utilcpp/PosixRegex.hpp is in libui-utilcpp-dev 1.8.3-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | /**
* @file
* @brief Posixregex, descriptors and sockets.
*/
#ifndef UI_UTIL_POSIXREGEX_HPP
#define UI_UTIL_POSIXREGEX_HPP
// STDC++
#include <string>
// POSIX C
#include <regex.h>
// C++ libraries
#include <ui-utilcpp/Exception.hpp>
namespace UI {
namespace Util {
/** @example Regex.cpp Example on how to use the PosixRegex class. */
/** @brief Wrapper class for POSIX.2 regex functions.
*
* @note For the future, one might rather use the libboost's regexx implementation.
*
* @see regex(3)
* @bug Not fully encapsulated; flags must be given using the values from regex.h; Catched
* exception code must be compared against the reg_errcode_t defined in regex.h.
* @bug Does not support multiple matches (seems this does not work anyway currently)
* @bug Does not support clear text error reporting as via regerror.
*/
class PosixRegex
{
private:
std::string getErrorMessage(int result) const;
public:
/** @brief Exceptions we might throw. */
typedef CodeException<reg_errcode_t> Exception;
/** @brief Helper class representing match data. */
class Match
{
public:
Match(): matches(false), begin(0), end(0) {}
/** Do we have a match? */
bool matches;
/** If yes: where it begins */
unsigned begin;
/** If yes: where it ends */
unsigned end;
};
/**
* @param regex The regular expression
* @param cflags Flags as described in regex(3)
*/
PosixRegex(std::string const & regex, int cflags=0) throw(Exception);
/** */
~PosixRegex();
/** @brief Check if text matches, and return the (first) match.
*
* @param text Text to examine.
* @param eflags Flags as described in regex(3).
* @returns First match found; if no match, match.matches will be false.
*/
Match runMatch(std::string const & text, int eflags=0) throw(Exception);
/** @brief Check if text matches.
*
* @param text Text to examine.
* @param eflags Flags as described in regex(3).
* @returns True if match found; else false.
*/
bool run(std::string const & text, int eflags=0) throw(Exception);
private:
regex_t preg_;
};
}}
#endif
|