diff --git a/libretroshare/src/libretroshare.pro b/libretroshare/src/libretroshare.pro index 85186f776..d2d0f7880 100644 --- a/libretroshare/src/libretroshare.pro +++ b/libretroshare/src/libretroshare.pro @@ -89,6 +89,7 @@ PUBLIC_HEADERS = retroshare/rsdisc.h \ retroshare/rsexpr.h \ retroshare/rsfiles.h \ retroshare/rshistory.h \ + retroshare/rsids.h \ retroshare/rsiface.h \ retroshare/rsinit.h \ retroshare/rsplugin.h \ diff --git a/libretroshare/src/retroshare/rsids.h b/libretroshare/src/retroshare/rsids.h index 8d2f498a0..d293634ac 100644 --- a/libretroshare/src/retroshare/rsids.h +++ b/libretroshare/src/retroshare/rsids.h @@ -160,38 +160,35 @@ template s template t_RsGenericIdType::t_RsGenericIdType(const std::string& s) { - try + int n=0; + if(s.length() != ID_SIZE_IN_BYTES*2) { - int n=0; - if(s.length() != ID_SIZE_IN_BYTES*2) + std::cerr << "t_RsGenericIdType<>::t_RsGenericIdType(std::string&): supplied string in constructor has wrong size." << std::endl; + clear(); + return; + } + + for(uint32_t i = 0; i < ID_SIZE_IN_BYTES; ++i) + { + bytes[i] = 0 ; + + for(int k=0;k<2;++k) { - throw std::runtime_error("t_RsGenericIdType<>::t_RsGenericIdType(std::string&): supplied string in constructor has wrong size.") ; - } + char b = s[n++] ; - for(uint32_t i = 0; i < ID_SIZE_IN_BYTES; ++i) - { - bytes[i] = 0 ; - - for(int k=0;k<2;++k) - { - char b = s[n++] ; - - if(b >= 'A' && b <= 'F') - bytes[i] += (b-'A'+10) << 4*(1-k) ; - else if(b >= 'a' && b <= 'f') - bytes[i] += (b-'a'+10) << 4*(1-k) ; - else if(b >= '0' && b <= '9') - bytes[i] += (b-'0') << 4*(1-k) ; - else - throw std::runtime_error("t_RsGenericIdType<>::t_RsGenericIdType(std::string&): supplied string is not purely hexadecimal") ; + if(b >= 'A' && b <= 'F') + bytes[i] += (b-'A'+10) << 4*(1-k) ; + else if(b >= 'a' && b <= 'f') + bytes[i] += (b-'a'+10) << 4*(1-k) ; + else if(b >= '0' && b <= '9') + bytes[i] += (b-'0') << 4*(1-k) ; + else { + std::cerr << "t_RsGenericIdType<>::t_RsGenericIdType(std::string&): supplied string is not purely hexadecimal" << std::endl; + clear(); + return; } } } - catch(std::exception& e) - { - std::cerr << e.what() << std::endl; - clear() ; - } } template t_RsGenericIdType::t_RsGenericIdType(const unsigned char *mem)