Razvoj programa devconf

Definirane funkcije

Datoteka main.cpp

Functions

QString takeArg(QList<QString> &arglist, const QString &defaultValue = "")

Take the first argument from a list of arguments, then pop it.

Parameters
  • arglist – The list of arguments.

  • defaultValue – Fallback value in case arglist is empty.

Returns

The first argument from arglist.

QString templateDir()

Obtain template directory. Uses the environment variable DEVCONF_TEMPLATE_DIR if set, otherwise use a default system path.

bool copyTemplate(const QString &targetDir)

Generate template JSON files in the specified directory.

This function is to be called when the --template option is specified in the command line.

Parameters

targetDir – The target directory

Returns

Whether the operation was successful.

void generateOutputFiles(const QString &inputDir, const QString &outputDir)
int initMbedWorkspace(const QString &outputDir)
int main(int argc, char *argv[])

Datoteka file.h

Definira operacije sa datotekama koje se koriste u projektu. To su uglavnom funkcije koje na osnovu templejt datoteke i podataka učitanih iz JSON datoteka generišu izlazne fajlove koji će se smjestiti u MBED workspace.

Functions

bool copyFile(const QString &source, const QString &dest)

Copy the file source into the file destination, thereby creating the necessary output directory structure if necessary.

void substituteInFile(const QString &source, const QString &dest, const QMap<QString, QString> &substitutions)

Copy source file to dest file with substitutions applied.

Parameters

substitutions – The keys are names of the substitution variables and the values are the strings with which to substitute them. Substitution variables must start with a ‘$’ in the source file.

void writeDeviceHeader(const Device &device, const QString &in, const QString &out)

Populate the template from file in with the data from device and write the result to the file out.

Example:

Device device = jsonParseDevice("factory_device.json");
write(device, "iot_device.h.in", "iot_device.h");

Note

in and out are file paths.

void writeDeviceImpl(const Device &device, const QString &out)
void writeMessageHandlers(const QString &in, const QString &out, const Device &device)
void writeMqttWrapperImpl(const QString &in, const QString &out, const Device &device)
namespace Devlib

Datoteka generator.h

Sadrži funkcije za generisanje C++ koda na osnovu podataka učitanih iz JSON datoteka.

C++ code generator

Functions

QString enumDefinition(const ValueSpec &spec)
QString functionDeclaration(const SingleFunction &fun)
QString functionDefinition(const SingleFunction &fun)
QString dataDeclaration(const Data &data)
QString dataDefinition(const Data &data)
QString messageHandlerDeclaration(const SingleFunction &fun)
QString messageHandlerDeclaration(const Data &data)
QString messageHandlerDefinition(const SingleFunction &fun)
QString messageHandlerDefinition(const Data &data)
QString mqttAutoSubscribeImpl(const QStringList &names)
void writeEnums(QTextStream &stream, QList<ValueSpec> enums)
void writeFunctionDeclarations(QTextStream &stream, QList<const SingleFunction*> functions)
void writeDataDeclarations(QTextStream &stream, QList<const Data*> functions)
void writeMessageHandlers(QTextStream &stream, QList<const SingleFunction*> functions)
void writeMessageHandlers(QTextStream &stream, QList<const Data*> data)
QString indented(QString str)