1
0
Fork 0
forked from lthn/blockchain

epee: clean up the mess with namespace misc_utils::parse + string tools

This commit is contained in:
sowle 2022-05-10 17:29:42 +02:00
parent 2707d1515d
commit 4066de04a1
No known key found for this signature in database
GPG key ID: C07A24B2D89D49FC
2 changed files with 12 additions and 25 deletions

View file

@ -30,7 +30,6 @@
namespace epee
{
using namespace misc_utils::parse;
namespace serialization
{
namespace json
@ -86,7 +85,7 @@ namespace epee
switch(*it)
{
case '"':
match_string2(it, buf_end, name);
misc_utils::parse::match_string2(it, buf_end, name);
state = match_state_waiting_separator;
break;
case '}':
@ -107,7 +106,7 @@ namespace epee
if(*it == '"')
{//just a named string value started
std::string val;
match_string2(it, buf_end, val);
misc_utils::parse::match_string2(it, buf_end, val);
//insert text value
stg.set_value(name, val, current_section);
state = match_state_wonder_after_value;
@ -115,7 +114,7 @@ namespace epee
{//just a named number value started
std::string val;
bool is_v_float = false;bool is_signed = false;
match_number2(it, buf_end, val, is_v_float, is_signed);
misc_utils::parse::match_number2(it, buf_end, val, is_v_float, is_signed);
if(!is_v_float)
{
if(is_signed)
@ -136,7 +135,7 @@ namespace epee
}else if(isalpha(*it) )
{// could be null, true or false
std::string word;
match_word2(it, buf_end, word);
misc_utils::parse::match_word2(it, buf_end, word);
if(boost::iequals(word, "null"))
{
state = match_state_wonder_after_value;
@ -191,7 +190,7 @@ namespace epee
{
//mean array of strings
std::string val;
match_string2(it, buf_end, val);
misc_utils::parse::match_string2(it, buf_end, val);
h_array = stg.insert_first_value(name, val, current_section);
CHECK_AND_ASSERT_THROW_MES(h_array, " failed to insert values entry");
state = match_state_array_after_value;
@ -200,7 +199,7 @@ namespace epee
{//array of numbers value started
std::string val;
bool is_v_float = false;bool is_signed_val = false;
match_number2(it, buf_end, val, is_v_float, is_signed_val);
misc_utils::parse::match_number2(it, buf_end, val, is_v_float, is_signed_val);
if(!is_v_float)
{
int64_t nval = boost::lexical_cast<int64_t>(val);//bool res = string_tools::string_to_num_fast(val, nval);
@ -222,7 +221,7 @@ namespace epee
}else if(isalpha(*it) )
{// array of booleans
std::string word;
match_word2(it, buf_end, word);
misc_utils::parse::match_word2(it, buf_end, word);
if(boost::iequals(word, "true"))
{
h_array = stg.insert_first_value(name, true, current_section);
@ -266,7 +265,7 @@ namespace epee
if(*it == '"')
{
std::string val;
match_string2(it, buf_end, val);
misc_utils::parse::match_string2(it, buf_end, val);
bool res = stg.insert_next_value(h_array, val);
CHECK_AND_ASSERT_THROW_MES(res, "failed to insert values");
state = match_state_array_after_value;
@ -277,7 +276,7 @@ namespace epee
{//array of numbers value started
std::string val;
bool is_v_float = false;bool is_signed_val = false;
match_number2(it, buf_end, val, is_v_float, is_signed_val);
misc_utils::parse::match_number2(it, buf_end, val, is_v_float, is_signed_val);
bool insert_res = false;
if(!is_v_float)
{
@ -299,7 +298,7 @@ namespace epee
if(isalpha(*it) )
{// array of booleans
std::string word;
match_word2(it, buf_end, word);
misc_utils::parse::match_word2(it, buf_end, word);
if(boost::iequals(word, "true"))
{
bool r = stg.insert_next_value(h_array, true);

View file

@ -23,16 +23,11 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
#ifndef _STRING_TOOLS_H_
#define _STRING_TOOLS_H_
//#include <objbase.h>
#include <locale>
#include <cstdlib>
//#include <strsafe.h>
#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <boost/lexical_cast.hpp>
@ -322,13 +317,6 @@ POP_GCC_WARNINGS
return true;
}
/* template<typename t_type>
bool get_xparam_from_command_line(const std::map<std::string, std::string>& res, const std::basic_string<typename t_string::value_type> & key, t_type& val)
{
}
*/
template<class t_string, typename t_type>
bool get_xparam_from_command_line(const std::map<t_string, t_string>& res, const t_string & key, t_type& val)
{
@ -803,6 +791,6 @@ POP_GCC_WARNINGS
return buff;
}
#endif
}
}
} // namespace stringtools
} // namwspace epee
#endif //_STRING_TOOLS_H_