Skip to content

Commit

Permalink
Use boost regex in api if gcc/g++ < 4.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Sude- committed Aug 21, 2014
1 parent 6fa03e1 commit a51fb3e
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/api.cpp
Expand Up @@ -9,9 +9,16 @@
#include <cstdio>
#include <cstdlib>
#include <sstream>
#include <regex>
#include <jsoncpp/json/json.h>

#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 40900
# define _regex_namespace_ std
# include <regex>
#else
# define _regex_namespace_ boost
# include <boost/regex.hpp>
#endif

size_t writeMemoryCallback(char *ptr, size_t size, size_t nmemb, void *userp) {
std::ostringstream *stream = (std::ostringstream*)userp;
size_t count = size * nmemb;
Expand Down Expand Up @@ -367,11 +374,11 @@ gameDetails API::getGameDetails(const std::string& game_name, const unsigned int
if (lang & GlobalConstants::LANGUAGES[i].languageId)
{
// Try to find a patch
std::regex re(GlobalConstants::LANGUAGES[i].languageCode + "\\d+patch\\d+", std::regex_constants::icase); // regex for patch node names
_regex_namespace_::regex re(GlobalConstants::LANGUAGES[i].languageCode + "\\d+patch\\d+", _regex_namespace_::regex_constants::icase); // regex for patch node names
std::vector<std::string> patchnames;
for (unsigned int j = 0; j < membernames.size(); ++j)
{
if (std::regex_match(membernames[j], re))
if (_regex_namespace_::regex_match(membernames[j], re))
{ // Regex matches, we have a patch node
std::string patchname = membernames[j];
unsigned int platformId;
Expand Down Expand Up @@ -498,11 +505,11 @@ gameDetails API::getGameDetails(const std::string& game_name, const unsigned int
if (lang & GlobalConstants::LANGUAGES[i].languageId)
{
// Try to find a language pack
std::regex re(GlobalConstants::LANGUAGES[i].languageCode + "\\d+langpack\\d+", std::regex_constants::icase); // regex for language pack node names
_regex_namespace_::regex re(GlobalConstants::LANGUAGES[i].languageCode + "\\d+langpack\\d+", _regex_namespace_::regex_constants::icase); // regex for language pack node names
std::vector<std::string> langpacknames;
for (unsigned int j = 0; j < membernames.size(); ++j)
{
if (std::regex_match(membernames[j], re))
if (_regex_namespace_::regex_match(membernames[j], re))
langpacknames.push_back(membernames[j]);
}

Expand Down

0 comments on commit a51fb3e

Please sign in to comment.