Changeset 60:9f32f8adb088 in finroc_plugins_data_ports


Ignore:
Timestamp:
03.03.2014 23:37:40 (5 years ago)
Author:
Max Reichardt <mreichardt@…>
Branch:
13.10
Children:
61:32551dd58033, 74:f968afdce0c3
Phase:
public
Message:

Removed boost dependency and fixed bug in string deserialization of tNumber (units containing '/' character are now correctly recognized)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • numeric/tNumber.cpp

    r46 r60  
    3636#include "core/definitions.h" 
    3737#include "core/log_messages.h" 
    38 #include <boost/algorithm/string.hpp> 
    3938 
    4039//---------------------------------------------------------------------- 
     
    207206} 
    208207 
    209 // TODO: This implementation is could be nicer 
     208// TODO: This implementation could be nicer 
    210209rrlib::serialization::tStringInputStream &operator >> (rrlib::serialization::tStringInputStream& stream, tNumber& number) 
    211210{ 
    212211  // scan for unit 
    213   tString complete_string = stream.ReadWhile("-.", rrlib::serialization::tStringInputStream::cDIGIT | rrlib::serialization::tStringInputStream::cWHITESPACE | rrlib::serialization::tStringInputStream::cLETTER, true); 
     212  tString complete_string = stream.ReadWhile("-./", rrlib::serialization::tStringInputStream::cDIGIT | rrlib::serialization::tStringInputStream::cWHITESPACE | rrlib::serialization::tStringInputStream::cLETTER, true); 
    214213  tString number_string = complete_string; 
    215214  tUnit unit; 
     
    223222        continue;  // exponent in decimal notation 
    224223      } 
    225       number_string = boost::trim_copy(complete_string.substr(0, i)); 
    226       tString unit_string = boost::trim_copy(complete_string.substr(i)); 
     224      number_string = complete_string.substr(0, i); // trimming not necessary, as ato* functions do this 
     225      tString unit_string = complete_string.substr(i); // first character is letter 
     226      assert(unit_string.length() > 0 && isalpha(unit_string[0])); 
     227      while (isspace(unit_string.back())) // trim back 
     228      { 
     229        unit_string.erase(unit_string.length() - 1); 
     230      } 
    227231      unit = tUnit::GetUnit(unit_string); 
    228232      break; 
Note: See TracChangeset for help on using the changeset viewer.