edbee - Qt Editor Library
Public Member Functions | Protected Member Functions | List of all members
edbee::JsonParser Class Reference

A Json Parser that supports strings in json sources! standard json doesn't support comments. This class strips the comments before passing it to qt the comments are replaced by spaces, this way the line-numbers and column numbers will stay the same. More...

#include <jsonparser.h>

+ Collaboration diagram for edbee::JsonParser:

Public Member Functions

 JsonParser ()
 Constructs the jsonparser. More...
 
virtual ~JsonParser ()
 The parser destructor. More...
 
bool parse (const QString &fileName)
 loads the given keymap file returns true on success More...
 
bool parse (QIODevice *device)
 Parses the given QIODevice. More...
 
bool parse (const QByteArray &bytesIn)
 opens the given bytes as a json document More...
 
QVariant result ()
 Returns the result of the json parsing. More...
 
void clearErrors ()
 Clears the error flags/variables. More...
 
QString errorMessage () const
 Returns the errormessage. More...
 
int errorLine () const
 returns the line number of the error More...
 
int errorColumn () const
 Returns the error column. More...
 
QString fullErrorMessage () const
 Returns the full eror message. More...
 

Protected Member Functions

QByteArray stripCommentsFromJson (const QByteArray &bytesIn)
 reads all bytes from the io device, while removing comments and keeping the number of lines quick and dirty 'lexer' that replaces every comment by spaces (so the number of charactes keeps the same) More...
 

Detailed Description

A Json Parser that supports strings in json sources! standard json doesn't support comments. This class strips the comments before passing it to qt the comments are replaced by spaces, this way the line-numbers and column numbers will stay the same.

Constructor & Destructor Documentation

◆ JsonParser()

edbee::JsonParser::JsonParser ( )

Constructs the jsonparser.

◆ ~JsonParser()

edbee::JsonParser::~JsonParser ( )
virtual

The parser destructor.

Member Function Documentation

◆ clearErrors()

void edbee::JsonParser::clearErrors ( )

Clears the error flags/variables.

◆ errorColumn()

int edbee::JsonParser::errorColumn ( ) const

Returns the error column.

◆ errorLine()

int edbee::JsonParser::errorLine ( ) const

returns the line number of the error

◆ errorMessage()

QString edbee::JsonParser::errorMessage ( ) const

Returns the errormessage.

◆ fullErrorMessage()

QString edbee::JsonParser::fullErrorMessage ( ) const

Returns the full eror message.

◆ parse() [1/3]

bool edbee::JsonParser::parse ( const QString &  fileName)

loads the given keymap file returns true on success

Parameters
filenamethe filename to parse
Returns
true if the file was parsed

◆ parse() [2/3]

bool edbee::JsonParser::parse ( QIODevice *  device)

Parses the given QIODevice.

Parameters
devicethe device to parse the json data
Returns
true if the file was successfully parsed

◆ parse() [3/3]

bool edbee::JsonParser::parse ( const QByteArray &  bytesIn)

opens the given bytes as a json document

Parameters
bytesInthe bytes of the Json document
Returns
true if the data was succeeful parsed

◆ result()

QVariant edbee::JsonParser::result ( )

Returns the result of the json parsing.

◆ stripCommentsFromJson()

QByteArray edbee::JsonParser::stripCommentsFromJson ( const QByteArray &  bytesIn)
protected

reads all bytes from the io device, while removing comments and keeping the number of lines quick and dirty 'lexer' that replaces every comment by spaces (so the number of charactes keeps the same)


The documentation for this class was generated from the following files: