revert to old boost based regex as GCC does not properly implement it prior to GCC 4.90

This commit is contained in:
Dennis Luxen 2014-05-20 14:20:09 +02:00
parent e28e45f38e
commit d53eb881c2

View File

@ -32,6 +32,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
#include <boost/regex.hpp>
#include <regex>
#include <string>
@ -40,21 +41,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
inline std::string ReadIniFileAndLowerContents(const boost::filesystem::path &path)
{
boost::filesystem::fstream config_stream(path);
std::string input_str((std::istreambuf_iterator<char>(config_stream)),
std::string ini_file_content((std::istreambuf_iterator<char>(config_stream)),
std::istreambuf_iterator<char>());
std::regex regex("\\w+=");
std::string output = input_str;
const std::sregex_token_iterator end;
for (std::sregex_token_iterator i(input_str.begin(), input_str.end(), regex); i != end; ++i)
{
std::string match = *i;
std::string new_regex = *i;
std::transform(new_regex.begin(), new_regex.end(), new_regex.begin(), ::tolower);
SimpleLogger().Write() << match << " - " << new_regex;
output = std::regex_replace(output, std::regex(match), new_regex);
}
return output;
boost::regex regex( "^([^=]*)" ); //match from start of line to '='
std::string format( "\\L$1\\E" ); //replace with downcased substring
return boost::regex_replace( ini_file_content, regex, format );
}
#endif // INI_FILE_UTIL_H