| 170 | const unsigned char* first, const unsigned char* last, value& v ); |
| 171 | |
| 172 | const unsigned char* |
| 173 | parse_cbor_number( |
| 174 | const unsigned char* first, const unsigned char* last, unsigned char ch, std::uint64_t& n ) |
| 175 | { |
| 176 | unsigned char cv = ch & 31; |
| 177 | |
| 178 | if( cv < 24 ) |
| 179 | { |
| 180 | n = cv; |
| 181 | } |
| 182 | else if( cv == 24 ) |
| 183 | { |
| 184 | ensure( 1, first, last ); |
| 185 | n = *first++; |
| 186 | } |
| 187 | else if( cv == 25 ) |
| 188 | { |
| 189 | ensure( 2, first, last ); |
| 190 | n = boost::endian::load_big_u16( first ); |
| 191 | first += 2; |
| 192 | } |
| 193 | else if( cv == 26 ) |
| 194 | { |
| 195 | ensure( 4, first, last ); |
| 196 | n = boost::endian::load_big_u32( first ); |
| 197 | first += 4; |
| 198 | } |
| 199 | else if( cv == 27 ) |
| 200 | { |
| 201 | ensure( 8, first, last ); |
| 202 | n = boost::endian::load_big_u64( first ); |
| 203 | first += 8; |
| 204 | } |
| 205 | else if( cv == 31 ) |
| 206 | { |
| 207 | // infinite array/object |
| 208 | throw_format_error( "Infinite sequences aren't supported" ); |
| 209 | } |
| 210 | else |
| 211 | { |
| 212 | throw_format_error( "Invalid minor type" ); |
| 213 | } |
| 214 | |
| 215 | return first; |
| 216 | } |
| 217 | |
| 218 | const unsigned char* |
| 219 | parse_cbor_string( |
no test coverage detected