Hello All!

Please tell me if I am wrong. But now soci just cannot read 64bit numbers. File "soci-test1.cpp" show how it fails. As I've found std::stringstream actually is guilty what can be seen in "sstream.cpp".

Thanks

--
Best regards, Michael Evdokimov
Network Solutions, Moscow, Russia, Office: +7-495-7950677, Mobile: +7-963-6054013
Web: www.lanbilling.ru, www.lanbilling.tv, www.helpdesk2.ru
#include <soci/soci.h>
#include <soci/soci-mysql.h>
#include <iostream>

int main()
{
  soci::session db( soci::mysql, "user=root dbname=billing" );
  db << "CREATE TEMPORARY TABLE T( num bigint(20) unsigned )";
  db << "INSERT INTO T SET num = 18446744073709551615";
  soci::row v;
  db << "SELECT * FROM T", into( v );
  return 0;
}

#include <iostream>
#include <sstream>
#include <stdexcept>

void parse_num(char const *buf, long long& x)
{
  std::stringstream iss(buf);
  iss >> x;
  if (iss.fail() || (iss.eof() == false))
  {
    std::cout << "post   = " << x << std::endl;
    if( iss.fail() )
      std::cout << "iss fail" << std::endl;
    if( iss.eof() == false )
      std::cout << "iss eof fail" << std::endl;
    throw std::runtime_error("Cannot convert data.");
  }
}

int main()
{
  const char* source = "18446744073709551615";
  std::cout << "source = " << source << std::endl;
  long long value = 0;
  parse_num( source, value );
  std::cout << "parsed: " << value << std::endl;
  return 0;
}
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Soci-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/soci-users

Reply via email to