Mercurial > code
diff C++/Parser.cpp @ 205:9f22ce5f1b39
Parser: rename getValue, add operator==
author | David Demelier <markand@malikania.fr> |
---|---|
date | Sun, 16 Feb 2014 12:39:03 +0100 |
parents | 1ffe6d4937b7 |
children | 3b0e276f0866 |
line wrap: on
line diff
--- a/C++/Parser.cpp Sun Feb 16 12:38:49 2014 +0100 +++ b/C++/Parser.cpp Sun Feb 16 12:39:03 2014 +0100 @@ -1,7 +1,7 @@ /* * Parser.h -- config file parser * - * Copyright (c) 2011, 2012, 2013 David Demelier <markand@malikania.fr> + * Copyright (c) 2013, 2014 David Demelier <markand@malikania.fr> * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -69,6 +69,11 @@ return m_options.end(); } +bool operator==(const Section &s1, const Section &s2) +{ + return s1.m_name == s2.m_name && s1.m_options == s2.m_options; +} + /* -------------------------------------------------------- * Parser private members * -------------------------------------------------------- */ @@ -210,7 +215,7 @@ file.open(m_path.c_str()); if (!file.is_open()) - throw std::runtime_error(m_path + std::string(std::strerror(errno))); + throw std::runtime_error(m_path + ": " + std::string(std::strerror(errno))); while (std::getline(file, line)) readLine(lineno++, line); @@ -288,3 +293,11 @@ { std::cout << "line " << number << ": " << message << std::endl; } + +bool operator==(const Parser &p1, const Parser &p2) +{ + return p1.m_sections == p2.m_sections && + p1.m_path == p2.m_path && + p1.m_tuning == p2.m_tuning && + p1.m_commentChar == p2.m_commentChar; +}