Skip to content

Commit

Permalink
switch to std::regex
Browse files Browse the repository at this point in the history
  • Loading branch information
Andersbakken committed Mar 1, 2015
1 parent 3fe0525 commit 10700c6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 122 deletions.
22 changes: 22 additions & 0 deletions rct/Rct.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <rct/Path.h>
#include <rct/List.h>
#include <sys/select.h>
#include <regex>

namespace Rct {

Expand All @@ -21,6 +22,27 @@ constexpr size_t countof(T(&)[N])

enum { Max_USec = 1000000 };

inline int indexIn(const String &string, const std::regex &rx)
{
std::cmatch match;
if (std::regex_match(string.constData(), match, rx) && !match.empty())
return match.position(0);
return -1;
}

inline bool contains(const char *str, const std::regex &rx, std::cmatch *match = 0)
{
std::cmatch null;
std::cmatch &m = match ? *match : null;
return std::regex_match(str, m, rx);
}

inline bool contains(const String &str, const std::regex &rx, std::cmatch *match = 0)
{
return contains(str.constData(), rx, match);
}


String shortOptions(const option *longOptions);
int readLine(FILE *f, char *buf = 0, int max = -1);
String readAll(FILE *f, int max = -1);
Expand Down
122 changes: 0 additions & 122 deletions rct/RegExp.h

This file was deleted.

0 comments on commit 10700c6

Please sign in to comment.