📝 documentation
This commit is contained in:
		
							parent
							
								
									10bad9381d
								
							
						
					
					
						commit
						241eea0c0e
					
				
					 1 changed files with 24 additions and 7 deletions
				
			
		
							
								
								
									
										31
									
								
								src/json.hpp
									
										
									
									
									
								
							
							
						
						
									
										31
									
								
								src/json.hpp
									
										
									
									
									
								
							| 
						 | 
					@ -5543,8 +5543,9 @@ class binary_reader
 | 
				
			||||||
    /*!
 | 
					    /*!
 | 
				
			||||||
    @brief reads a UBJSON string
 | 
					    @brief reads a UBJSON string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    This function first reads starting bytes to determine the expected
 | 
					    This function is either called after reading the 'S' byte explicitly
 | 
				
			||||||
    string length and then copies this number of bytes into a string.
 | 
					    indicating a string, or in case of an object key where the 'S' byte can be
 | 
				
			||||||
 | 
					    left out.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @param[in] get_char  whether a new character should be retrieved from the
 | 
					    @param[in] get_char  whether a new character should be retrieved from the
 | 
				
			||||||
                         input (true, default) or whether the last read
 | 
					                         input (true, default) or whether the last read
 | 
				
			||||||
| 
						 | 
					@ -5559,7 +5560,7 @@ class binary_reader
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if (get_char)
 | 
					        if (get_char)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            get();
 | 
					            get();  // TODO: may we ignore N here?
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        check_eof();
 | 
					        check_eof();
 | 
				
			||||||
| 
						 | 
					@ -5584,6 +5585,14 @@ class binary_reader
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /*!
 | 
				
			||||||
 | 
					    @brief determine the type and size for a container
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    In the optimized UBJSON format, a type and a size can be provided to allow
 | 
				
			||||||
 | 
					    for a more compact representation.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @return pair of the size and the type
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
    std::pair<std::size_t, int> get_ubjson_size_type()
 | 
					    std::pair<std::size_t, int> get_ubjson_size_type()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        std::size_t sz = std::string::npos;
 | 
					        std::size_t sz = std::string::npos;
 | 
				
			||||||
| 
						 | 
					@ -5593,14 +5602,16 @@ class binary_reader
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (current == '$')
 | 
					        if (current == '$')
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            get();  // must not ignore 'N', because 'N' maybe the type
 | 
					            tc = get();  // must not ignore 'N', because 'N' maybe the type
 | 
				
			||||||
            check_eof();
 | 
					            check_eof();
 | 
				
			||||||
            tc = current;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            get_ignore_noop();
 | 
					            get_ignore_noop();
 | 
				
			||||||
            if (current != '#')
 | 
					            if (current != '#')
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                assert(false);
 | 
					                std::stringstream ss;
 | 
				
			||||||
 | 
					                ss << std::setw(2) << std::uppercase << std::setfill('0') << std::hex << current;
 | 
				
			||||||
 | 
					                JSON_THROW(parse_error::create(112, chars_read,
 | 
				
			||||||
 | 
					                                               "expected '#' after UBJSON type information; last byte: 0x" + ss.str()));
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            sz = parse_ubjson_internal();
 | 
					            sz = parse_ubjson_internal();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					@ -5646,7 +5657,13 @@ class binary_reader
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                get();
 | 
					                get();
 | 
				
			||||||
                check_eof();
 | 
					                check_eof();
 | 
				
			||||||
                assert(0 <= current and current <= 127);
 | 
					                if (JSON_UNLIKELY(not(0 <= current and current <= 127)))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    std::stringstream ss;
 | 
				
			||||||
 | 
					                    ss << std::setw(2) << std::uppercase << std::setfill('0') << std::hex << current;
 | 
				
			||||||
 | 
					                    JSON_THROW(parse_error::create(113, chars_read,
 | 
				
			||||||
 | 
					                                                   "byte after 'C' must be in range 0x00..0x7F; last byte: 0x" + ss.str()));
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
                return std::string(1, static_cast<char>(current));
 | 
					                return std::string(1, static_cast<char>(current));
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue