![]()  | 
  
    CUGL 2.0
    
   Cornell University Game Library 
   | 
 
#include <CUJsonReader.h>
  
Public Member Functions | |
| std::string | readJsonString () | 
| std::shared_ptr< JsonValue > | readJson () | 
  Public Member Functions inherited from cugl::TextReader | |
| TextReader () | |
| ~TextReader () | |
| bool | init (const std::string file) | 
| bool | init (const std::string file, unsigned int capacity) | 
| bool | initWithAsset (const std::string file) | 
| bool | initWithAsset (const std::string file, unsigned int capacity) | 
| void | reset () | 
| void | close () | 
| bool | ready () const | 
| char | read () | 
| std::string & | read (std::string &data) | 
| std::string | readUTF8 () | 
| std::string & | readUTF8 (std::string &data) | 
| std::string | readLine () | 
| std::string & | readLine (std::string &data) | 
| std::string | readAll () | 
| std::string & | readAll (std::string &data) | 
| void | skip () | 
Static Public Member Functions | |
| static std::shared_ptr< JsonReader > | alloc (const std::string file) | 
| static std::shared_ptr< JsonReader > | alloc (const std::string file, unsigned int capacity) | 
| static std::shared_ptr< JsonReader > | allocWithAsset (const std::string file) | 
| static std::shared_ptr< JsonReader > | allocWithAsset (const std::string file, unsigned int capacity) | 
  Static Public Member Functions inherited from cugl::TextReader | |
| static std::shared_ptr< TextReader > | alloc (const std::string file) | 
| static std::shared_ptr< TextReader > | alloc (const std::string file, unsigned int capacity) | 
| static std::shared_ptr< TextReader > | allocWithAsset (const std::string file) | 
| static std::shared_ptr< TextReader > | allocWithAsset (const std::string file, unsigned int capacity) | 
Additional Inherited Members | |
  Protected Member Functions inherited from cugl::TextReader | |
| void | fill () | 
  Protected Attributes inherited from cugl::TextReader | |
| std::string | _name | 
| SDL_RWops * | _stream | 
| Sint64 | _ssize | 
| Sint64 | _scursor | 
| std::string | _sbuffer | 
| char * | _cbuffer | 
| Uint32 | _capacity | 
| Sint32 | _bufoff | 
Simple JSON extension to TextReader.
This class not require that the entire file conform to JSON standards; it can read a JSON string embedded in a larger text file. This allows for maximum flexibility in encoding/decoding JSON data.
By default, this class (and every class in the io package) accesses the application save directory {
      
  | 
  inlinestatic | 
Returns a newly allocated reader for the given file.
The reader will have the default buffer capacity for reading chunks from the file.
If the file is a relative path, this reader will look for the file in the application save directory {
| file | the path (absolute or relative) to the file | 
      
  | 
  inlinestatic | 
Returns a newly allocated reader for the given file with the specified capacity.
If the file is a relative path, this reader will look for the file in the application save directory {
| file | the path (absolute or relative) to the file | 
| capacity | the buffer capacity for reading chunks | 
      
  | 
  inlinestatic | 
Returns a newly allocated reader for the given file.
The reader will have the default buffer capacity for reading chunks from the file.
This initializer assumes that the file name is a relative path. It will search the application assert directory {
| file | the relative path to the file | 
      
  | 
  inlinestatic | 
Returns a newly allocated reader for the given file with the specified capacity.
This initializer assumes that the file name is a relative path. It will search the application assert directory {
| file | the relative path to the file | 
| capacity | the buffer capacity for reading chunks | 
| std::shared_ptr<JsonValue> cugl::JsonReader::readJson | ( | ) | 
Returns a newly allocated JsonValue for the next available JSON string.
This method uses readJsonString() to extract the next available JSON string and constructs a JsonValue from that.
If there is a parsing error, this method will return nullptr. Detailed information about the parsing error will be passed to an assert. Hence error messages are suppressed if asserts are turned off.
| std::string cugl::JsonReader::readJsonString | ( | ) | 
Returns the next available JSON string
A JSON string is defined to be any string within matching braces {}. This method will skip over any whitespace to find the first brace. If the first non-whitespace character is not a brace, this method will fail.
If the first non-whitespace character is a brace, it will advance until it reaches the matching brace, or the end of the file, whichever is first. If it finds no matching brace, it will fail.
 1.8.16