LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SExpression Class Referencefinal

The SExpression class. More...

#include <sexpression.h>

+ Collaboration diagram for SExpression:

Public Types

enum  Type
 

Public Member Functions

 SExpression () noexcept
 
 SExpression (const SExpression &other) noexcept
 
 ~SExpression () noexcept
 
const FilePathgetFilePath () const noexcept
 
Type getType () const noexcept
 
bool isList () const noexcept
 
bool isToken () const noexcept
 
bool isString () const noexcept
 
bool isLineBreak () const noexcept
 
bool isMultiLineList () const noexcept
 
const QString & getName () const
 
const QString & getStringOrToken (bool throwIfEmpty=false) const
 
const QList< SExpression > & getChildren () const
 
QList< SExpressiongetChildren (const QString &name) const noexcept
 
const SExpressiongetChildByIndex (int index) const
 
const SExpressiontryGetChildByPath (const QString &path) const noexcept
 
const SExpressiongetChildByPath (const QString &path) const
 
template<typename T >
getValue (bool throwIfEmpty=false) const
 
template<typename T >
getValueByPath (const QString &path, bool throwIfEmpty=false) const
 
template<typename T >
getValueOfFirstChild (bool throwIfEmpty=false) const
 
SExpressionappendLineBreak ()
 
SExpressionappendList (const QString &name, bool linebreak)
 
SExpressionappendChild (const SExpression &child, bool linebreak)
 
template<typename T >
SExpressionappendChild (const T &obj)
 
template<typename T >
SExpressionappendChild (const QString &child, const T &obj, bool linebreak)
 
void removeLineBreaks () noexcept
 
QString toString (int indent) const
 
SExpressionoperator= (const SExpression &rhs) noexcept
 

Static Public Member Functions

static SExpression createList (const QString &name)
 
static SExpression createToken (const QString &token)
 
static SExpression createString (const QString &string)
 
static SExpression createLineBreak ()
 
static SExpression parse (const QString &str, const FilePath &filePath)
 

Private Member Functions

 SExpression (Type type, const QString &value)
 
 SExpression (sexpresso::Sexp &sexp, const FilePath &filePath)
 
QString escapeString (const QString &string) const noexcept
 
bool isValidListName (const QString &name) const noexcept
 
bool isValidToken (const QString &token) const noexcept
 

Private Attributes

Type mType
 
QString mValue
 either a list name, a token or a string More...
 
QList< SExpressionmChildren
 
FilePath mFilePath
 

Detailed Description

The SExpression class.

Author
ubruhin
Date
2017-10-17

Member Enumeration Documentation

enum Type
strong
Enumerator
List 

has a tag name and an arbitrary number of children

Token 

values without quotes (e.g. -12.34)

String 

values with double quotes (e.g. "Foo!")

LineBreak 

manual line break inside a List

Constructor & Destructor Documentation

SExpression ( )
noexcept

+ Here is the caller graph for this function:

SExpression ( const SExpression other)
noexcept
~SExpression ( )
noexcept
SExpression ( Type  type,
const QString &  value 
)
private
SExpression ( sexpresso::Sexp &  sexp,
const FilePath filePath 
)
private

+ Here is the call graph for this function:

Member Function Documentation

const FilePath& getFilePath ( ) const
inlinenoexcept

+ Here is the caller graph for this function:

Type getType ( ) const
inlinenoexcept
bool isList ( ) const
inlinenoexcept

+ Here is the caller graph for this function:

bool isToken ( ) const
inlinenoexcept

+ Here is the caller graph for this function:

bool isString ( ) const
inlinenoexcept

+ Here is the caller graph for this function:

bool isLineBreak ( ) const
inlinenoexcept

+ Here is the caller graph for this function:

bool isMultiLineList ( ) const
noexcept

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const QString & getName ( ) const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const QString & getStringOrToken ( bool  throwIfEmpty = false) const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const QList<SExpression>& getChildren ( ) const
inline

+ Here is the caller graph for this function:

QList< SExpression > getChildren ( const QString &  name) const
noexcept

+ Here is the call graph for this function:

const SExpression & getChildByIndex ( int  index) const

+ Here is the caller graph for this function:

const SExpression * tryGetChildByPath ( const QString &  path) const
noexcept

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const SExpression & getChildByPath ( const QString &  path) const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

T getValue ( bool  throwIfEmpty = false) const
inline

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

T getValueByPath ( const QString &  path,
bool  throwIfEmpty = false 
) const
inline

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

T getValueOfFirstChild ( bool  throwIfEmpty = false) const
inline

+ Here is the caller graph for this function:

SExpression & appendLineBreak ( )

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SExpression & appendList ( const QString &  name,
bool  linebreak 
)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SExpression & appendChild ( const SExpression child,
bool  linebreak 
)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SExpression& appendChild ( const T &  obj)
inline

+ Here is the call graph for this function:

SExpression& appendChild ( const QString &  child,
const T &  obj,
bool  linebreak 
)
inline

+ Here is the call graph for this function:

void removeLineBreaks ( )
noexcept
QString toString ( int  indent) const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SExpression & operator= ( const SExpression rhs)
noexcept
SExpression createList ( const QString &  name)
static

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SExpression createToken ( const QString &  token)
static

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SExpression createString ( const QString &  string)
static

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SExpression createLineBreak ( )
static

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SExpression parse ( const QString &  str,
const FilePath filePath 
)
static

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

QString escapeString ( const QString &  string) const
privatenoexcept

+ Here is the caller graph for this function:

bool isValidListName ( const QString &  name) const
privatenoexcept

+ Here is the caller graph for this function:

bool isValidToken ( const QString &  token) const
privatenoexcept

+ Here is the caller graph for this function:

Member Data Documentation

Type mType
private
QString mValue
private

either a list name, a token or a string

QList<SExpression> mChildren
private
FilePath mFilePath
private

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