2020#include < string.h>
2121
2222#include < algorithm>
23+ #include < charconv>
2324#include < string>
2425#include < vector>
2526
2627#include " base/endianconv.h"
2728#include " base/strings.h"
28- #include " boost/lexical_cast.hpp"
2929#include " proto/type.pb.h"
3030#include " sdk/base.h"
3131
@@ -56,19 +56,31 @@ static bool AppendColumnValue(const std::string& v, hybridse::sdk::DataType type
5656 return ok;
5757 }
5858 case hybridse::sdk::kTypeInt16 : {
59- return row->AppendInt16 (boost::lexical_cast<int16_t >(v));
59+ int16_t val = 0 ;
60+ if (auto ret = std::from_chars (v.data (), v.data () + v.size (), val); ret.ec != std::errc ()) {
61+ return false ;
62+ }
63+ return row->AppendInt16 (val);
6064 }
6165 case hybridse::sdk::kTypeInt32 : {
62- return row->AppendInt32 (boost::lexical_cast<int32_t >(v));
66+ int32_t val = 0 ;
67+ if (auto ret = std::from_chars (v.data (), v.data () + v.size (), val); ret.ec != std::errc ()) {
68+ return false ;
69+ }
70+ return row->AppendInt32 (val);
6371 }
6472 case hybridse::sdk::kTypeInt64 : {
65- return row->AppendInt64 (boost::lexical_cast<int64_t >(v));
73+ int64_t val = 0 ;
74+ if (auto ret = std::from_chars (v.data (), v.data () + v.size (), val); ret.ec != std::errc ()) {
75+ return false ;
76+ }
77+ return row->AppendInt64 (val);
6678 }
6779 case hybridse::sdk::kTypeFloat : {
68- return row->AppendFloat (boost::lexical_cast< float > (v));
80+ return row->AppendFloat (std::stof (v));
6981 }
7082 case hybridse::sdk::kTypeDouble : {
71- return row->AppendDouble (boost::lexical_cast< double > (v));
83+ return row->AppendDouble (std::stod (v));
7284 }
7385 case hybridse::sdk::kTypeString : {
7486 return row->AppendString (v);
@@ -79,13 +91,29 @@ static bool AppendColumnValue(const std::string& v, hybridse::sdk::DataType type
7991 if (parts.size () != 3 ) {
8092 return false ;
8193 }
82- auto year = boost::lexical_cast<int32_t >(parts[0 ]);
83- auto mon = boost::lexical_cast<int32_t >(parts[1 ]);
84- auto day = boost::lexical_cast<int32_t >(parts[2 ]);
94+ int32_t year = 0 ;
95+ int32_t mon = 0 ;
96+ int32_t day = 0 ;
97+ if (auto ret = std::from_chars (parts[0 ].data (), parts[0 ].data () + parts[0 ].size (), year);
98+ ret.ec != std::errc ()) {
99+ return false ;
100+ }
101+ if (auto ret = std::from_chars (parts[1 ].data (), parts[1 ].data () + parts[1 ].size (), mon);
102+ ret.ec != std::errc ()) {
103+ return false ;
104+ }
105+ if (auto ret = std::from_chars (parts[2 ].data (), parts[2 ].data () + parts[2 ].size (), day);
106+ ret.ec != std::errc ()) {
107+ return false ;
108+ }
85109 return row->AppendDate (year, mon, day);
86110 }
87111 case hybridse::sdk::kTypeTimestamp : {
88- return row->AppendTimestamp (boost::lexical_cast<int64_t >(v));
112+ int64_t val = 0 ;
113+ if (auto ret = std::from_chars (v.data (), v.data () + v.size (), val); ret.ec != std::errc ()) {
114+ return false ;
115+ }
116+ return row->AppendTimestamp (val);
89117 }
90118 default : {
91119 return false ;
0 commit comments