The SExpression class.
More...
#include <sexpression.h>
|
static bool | skipLineBreaks (const std::vector< std::unique_ptr< SExpression > > &children, int &index) noexcept |
|
static std::unique_ptr< SExpression > | parse (const QString &content, int &index, const FilePath &filePath, Mode mode) |
|
static std::unique_ptr< SExpression > | parseList (const QString &content, int &index, const FilePath &filePath, Mode mode) |
|
static QString | parseToken (const QString &content, int &index, const FilePath &filePath, Mode mode) |
|
static QString | parseString (const QString &content, int &index, const FilePath &filePath) |
|
static void | skipWhitespaceAndComments (const QString &content, int &index, bool skipNewline=false) |
|
static QString | escapeString (const QString &string) noexcept |
|
static bool | isValidToken (const QString &token, Mode mode) noexcept |
|
static bool | isValidTokenChar (const QChar &c, Mode mode) noexcept |
|
◆ Mode
Enumerator |
---|
LibrePCB | LibrePCB syntax (very strict)
|
Permissive | Compatibility with other tools (very permissive)
|
◆ Type
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
|
◆ SExpression() [1/3]
◆ SExpression() [2/3]
◆ ~SExpression()
◆ SExpression() [3/3]
◆ getFilePath()
◆ getType()
◆ isList()
◆ isToken()
◆ isString()
◆ isLineBreak()
bool isLineBreak |
( |
| ) |
const |
|
inlinenoexcept |
◆ getName()
const QString & getName |
( |
| ) |
const |
◆ getValue()
const QString & getValue |
( |
| ) |
const |
◆ getChildCount()
std::size_t getChildCount |
( |
| ) |
const |
|
inlinenoexcept |
◆ containsChild()
◆ getChild() [1/4]
◆ getChild() [2/4]
◆ getChildren() [1/4]
◆ getChildren() [2/4]
◆ getChildren() [3/4]
QList< SExpression * > getChildren |
( |
const QString & |
name | ) |
|
|
noexcept |
◆ getChildren() [4/4]
QList< const SExpression * > getChildren |
( |
const QString & |
name | ) |
const |
|
noexcept |
◆ getChild() [3/4]
Get a child by path.
This method allows to get a specific child, even nested child. Consider this S-Expression:
* (netsegment 3115f409-5e6c-4023-a8ab-06428ed0720a
* (via 2cc45b07-1bef-4340-9292-b54b011c70c5
* (position 35.91989 46.0375) (size 0.7) (drill 0.3) (shape round)
* )
* )
*
- To get the UUID of the net segment, use the path "@0" (first child).
- To get the whole "via" element (incl. children), use the path "via".
- To get the Y coordinate of the via, use the path "via/position/@1".
- Attention
- If there exist several childs with (the begin of) the specified path, only the first match is returned! So if the example above had more "via" elements, all after the first one would be ignored. And for example if the first "via" element had no "position" child, an exception is raised even if the following "via" elements do have a "position" child.
- Note
- In contrast to getChildren(), this method skips linebreak elements. So if you acces an element by index (e.g. "@3"), the n-th child which is not a linebreak will be returned.
- Parameters
-
path | The path to the child to get, separated by forward slashes '/'. To specify a child by index, use '@' followed by the index (e.g. '@1' to get the second child). |
- Returns
- A reference to the child of the specified path.
- Exceptions
-
◆ getChild() [4/4]
const SExpression & getChild |
( |
const QString & |
path | ) |
const |
◆ tryGetChild() [1/2]
Try get a child by path.
This is exactly the same as getChild(), but returns nullptr
if the specified child does not exist (instead of throwing an exception).
- Parameters
-
- Returns
- A pointer to the child of the specified path, if found. If no such child exists,
nullptr
is returned.
◆ tryGetChild() [2/2]
const SExpression * tryGetChild |
( |
const QString & |
path | ) |
const |
|
noexcept |
◆ setName()
void setName |
( |
const QString & |
name | ) |
|
◆ setValue()
void setValue |
( |
const QString & |
value | ) |
|
◆ ensureLineBreak()
◆ appendList()
◆ appendChild() [1/4]
void appendChild |
( |
std::unique_ptr< SExpression > |
child | ) |
|
◆ appendChild() [2/4]
◆ appendChild() [3/4]
void appendChild |
( |
const QString & |
child, |
|
|
std::unique_ptr< SExpression > |
obj |
|
) |
| |
|
inline |
◆ appendChild() [4/4]
SExpression & appendChild |
( |
const QString & |
child, |
|
|
const T & |
obj |
|
) |
| |
|
inline |
◆ removeChild()
◆ removeChildrenWithNodeRecursive()
void removeChildrenWithNodeRecursive |
( |
const SExpression & |
search | ) |
|
|
noexcept |
◆ replaceRecursive()
◆ toByteArray()
◆ operator==()
◆ operator!=()
◆ operator<()
◆ operator=()
◆ createList()
std::unique_ptr< SExpression > createList |
( |
const QString & |
name | ) |
|
|
static |
◆ createToken()
std::unique_ptr< SExpression > createToken |
( |
const QString & |
token | ) |
|
|
static |
◆ createString()
std::unique_ptr< SExpression > createString |
( |
const QString & |
string | ) |
|
|
static |
◆ createLineBreak()
◆ parse() [1/2]
◆ isMultiLine()
bool isMultiLine |
( |
| ) |
const |
|
privatenoexcept |
◆ skipLineBreaks()
bool skipLineBreaks |
( |
const std::vector< std::unique_ptr< SExpression > > & |
children, |
|
|
int & |
index |
|
) |
| |
|
staticprivatenoexcept |
◆ parse() [2/2]
std::unique_ptr< SExpression > parse |
( |
const QString & |
content, |
|
|
int & |
index, |
|
|
const FilePath & |
filePath, |
|
|
Mode |
mode |
|
) |
| |
|
staticprivate |
◆ parseList()
std::unique_ptr< SExpression > parseList |
( |
const QString & |
content, |
|
|
int & |
index, |
|
|
const FilePath & |
filePath, |
|
|
Mode |
mode |
|
) |
| |
|
staticprivate |
◆ parseToken()
QString parseToken |
( |
const QString & |
content, |
|
|
int & |
index, |
|
|
const FilePath & |
filePath, |
|
|
Mode |
mode |
|
) |
| |
|
staticprivate |
◆ parseString()
QString parseString |
( |
const QString & |
content, |
|
|
int & |
index, |
|
|
const FilePath & |
filePath |
|
) |
| |
|
staticprivate |
◆ skipWhitespaceAndComments()
void skipWhitespaceAndComments |
( |
const QString & |
content, |
|
|
int & |
index, |
|
|
bool |
skipNewline = false |
|
) |
| |
|
staticprivate |
◆ escapeString()
QString escapeString |
( |
const QString & |
string | ) |
|
|
staticprivatenoexcept |
◆ isValidToken()
bool isValidToken |
( |
const QString & |
token, |
|
|
Mode |
mode |
|
) |
| |
|
staticprivatenoexcept |
◆ isValidTokenChar()
bool isValidTokenChar |
( |
const QChar & |
c, |
|
|
Mode |
mode |
|
) |
| |
|
staticprivatenoexcept |
◆ toString()
QString toString |
( |
int |
indent, |
|
|
Mode |
mode |
|
) |
| const |
|
private |
◆ qHash
◆ mType
◆ mValue
either a list name, a token or a string
◆ mChildren
◆ mFilePath
The documentation for this class was generated from the following files: