|
pianod2
multisource multiuser scriptable networked music player
|
JSON formatter A simple JSON formatter using the Parsnip library. More...
#include <cstdlib>#include <unistd.h>#include <istream>#include <iostream>#include <fstream>#include "parsnip.h"
Classes | |
| struct | Options |
Enumerations | |
| enum class | Action { TIDY , VALIDATE , EXPLAIN , FLATTEN_W_DICT , FLATTEN_W_MEMBERS } |
Functions | |
| void | setprogname (const char *name) |
| const char * | getprogname (void) |
| void | render_exception (const char *filename, const Parsnip::Exception &ex) |
| Render a parsnip exception to standard error in a standard way. More... | |
| Parsnip::Data | read_json_file (const char *name, std::istream &src) |
| Read a JSON document from a stream. More... | |
| Parsnip::Data | load_json_file (const char *name) |
| Read in JSON from a file. More... | |
| bool | try_load_json_file (const char *name, Parsnip::Data &file_contents) |
| Read in JSON from a file. More... | |
| void | flatten (const Parsnip::Data &data, Action action, const std::string varname) |
| Reformat a JSON file into a series of assignments, perhaps for use with a shell script or diff. More... | |
| bool | process_file (const char *name, Parsnip::Data &data, const Options &options) |
| Take action on a file. More... | |
| void | usage () |
| Display command-line usage statement. More... | |
| int | main (int argc, char *const *argv) |
Variables | |
| static const char * | progname |
JSON formatter A simple JSON formatter using the Parsnip library.
|
strong |
| void flatten | ( | const Parsnip::Data & | data, |
| Action | action, | ||
| const std::string | varname | ||
| ) |
Reformat a JSON file into a series of assignments, perhaps for use with a shell script or diff.
| data | The data to reformat |
| action | Either FLATTEN_W_DICTIONARY or FLATTEN_W_MEMBERS. |
| varname | The "variable" name to which options/array specifiers are appended. |


| const char* getprogname | ( | void | ) |

| Parsnip::Data load_json_file | ( | const char * | name | ) |
Read in JSON from a file.
On error, exit with failure.


| int main | ( | int | argc, |
| char *const * | argv | ||
| ) |

| bool process_file | ( | const char * | name, |
| Parsnip::Data & | data, | ||
| const Options & | options | ||
| ) |
Take action on a file.
| name | The name of the file (for error reporting). |
| data | The contents of the file. |
| options | Options and data for the action to be taken. |


| Parsnip::Data read_json_file | ( | const char * | name, |
| std::istream & | src | ||
| ) |
Read a JSON document from a stream.
On error, exit with failure.


| void render_exception | ( | const char * | filename, |
| const Parsnip::Exception & | ex | ||
| ) |
Render a parsnip exception to standard error in a standard way.
| filename | The filename to which the exception pertains. |
| ex | The exception. |


| void setprogname | ( | const char * | name | ) |

| bool try_load_json_file | ( | const char * | name, |
| Parsnip::Data & | file_contents | ||
| ) |
| void usage | ( | ) |
Display command-line usage statement.


|
static |