NuriaProject Framework  0.1
The NuriaProject Framework
Public Types | Public Member Functions | List of all members
Nuria::JsonMetaObjectReader Class Reference

JsonMetaObjectReader is a parser for MetaObject data stored in JSON format as generated by Tria. More...

#include <jsonmetaobjectreader.hpp>

Inheritance diagram for Nuria::JsonMetaObjectReader:

Public Types

enum  Error {
  NoError = 0, JsonParseError, RootIsNotAnObject, FileIsNotAnObject,
  TypeIsNotAnObject, AnnotationsIsNotAnArray, BasesIsNotAnArray, ConstructorsIsNotAnArray,
  MemberMethodsIsNotAnArray, StaticMethodsIsNotAnArray, EnumsIsNotAnObject, FieldsIsNotAnObject,
  BasesContainsNonString, AnnotationIsNotAnObject, AnnotationNameIsNotAString, AnnotationValueHasUnknownType,
  MethodIsNotAnObject, MethodNameIsNotAString, MethodResultTypeIsNotAString, MethodArgumentsHaveDifferentLengths,
  MethodArgumentNamesIsNotAnArray, MethodArgumentNamesContainsNonString, MethodArgumentTypesIsNotAnArray, MethodArgumentTypesContainsNonString,
  EnumIsNotAnObject, EnumValuesIsNotAnObject, EnumValueObjectValueIsNotAnInteger, FieldIsNotAnObject,
  FieldTypeIsNotAString, FieldReadOnlyIsNotABoolean
}
 

Public Member Functions

 JsonMetaObjectReader (QObject *parent=0)
 
 ~JsonMetaObjectReader ()
 
MetaObjectMap metaObjects (const QString &sourceFile)
 
Error parse (const QJsonDocument &jsonDocument)
 
Error parse (const QJsonObject &root)
 
Error parse (const QByteArray &jsonData)
 
QStringList sourceFiles ()
 

Detailed Description

JsonMetaObjectReader is a parser for MetaObject data stored in JSON format as generated by Tria.

Usage
First, you'll need to tell Tria to generate JSON data by using the "-json-output" (Or "-j" for short) flag. Please refer to "-help" for further information. After that you can use JsonMetaObjectReader to read the data itself in again.

Please note that the JSON format can store information about multiple source files at once.

Warning
Nuria::MetaObject instances returned by methods of this class are owned by the instance. When the reader instance gets destroyed, all MetaObjects will be destroyed too!
Note
The JSON format is documented in Tria's source in src/jsongenerator.hpp
Limitations
Please note that a lot functionality is lost, for example MetaObjects created by this class are not able to call methods. Annotations are currently limited to POD-types and QString.

Member Enumeration Documentation

All possible error codes.

Enumerator
NoError 

No error occured.

JsonParseError 

The raw JSON data failed to parse.

RootIsNotAnObject 

The root of the json document must be an object.

FileIsNotAnObject 

All children of root must be objects.

AnnotationValueHasUnknownType 

The 'value' item must be of type bool, integer/number, array or object. If it's an array or object, all children of those must be of type bool, integer/number or string.

MethodArgumentsHaveDifferentLengths 

argumentNames.length != argumentTypes.length

Constructor & Destructor Documentation

Nuria::JsonMetaObjectReader::JsonMetaObjectReader ( QObject *  parent = 0)
explicit

Constructor.

See also
parse
Nuria::JsonMetaObjectReader::~JsonMetaObjectReader ( )

Destructor.

Member Function Documentation

MetaObjectMap Nuria::JsonMetaObjectReader::metaObjects ( const QString &  sourceFile)

Returns the map of all known types in sourceFile.

See also
sourceFiles
Error Nuria::JsonMetaObjectReader::parse ( const QJsonDocument &  jsonDocument)

Parses jsonDocument. The format is expected to match the one documented in Tria. Returns NoError on success. If a error occured the corresponding error code is returned.

Error Nuria::JsonMetaObjectReader::parse ( const QJsonObject &  root)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Error Nuria::JsonMetaObjectReader::parse ( const QByteArray &  jsonData)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

QStringList Nuria::JsonMetaObjectReader::sourceFiles ( )

Returns a list of all known source files.

See also
metaObjects

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