Class for handling JSON format options.
More...
|
class | Indention |
| A class to create small proxy objects that ease indention handling. More...
|
|
Class for handling JSON format options.
Base class to implement custom formatting. Purpose:
- individual output formatting
- normalization of DecimalString and IntegerString e.g. normalization of leading zeros
- escaping of special JSON control characters
- outputting the correct indention and symbols for "Value", "BulkDataURI", etc.
Usage Example:
#include "dcmtk/dcmdata/dcjson.h"
{
}
Implementing a custom formatter:
{
CustomJsonFormat(
const OFBool printMetaInfo = OFTrue)
{
}
{
return "\t";
}
}
◆ DcmJsonFormat()
DcmJsonFormat::DcmJsonFormat |
( |
const OFBool |
printMetaInfo | ) |
|
|
inline |
Constructor.
- Parameters
-
printMetaInfo | parameter that defines if meta information should be written |
◆ asBulkDataURI()
Check if an attribute should be exported as BulkDataURI.
Override this function to implement bulk data URI output.
- Parameters
-
tag | the tag of the attribute being printed, for letting the implementation decide how to handle it. |
uri | the resulting URI to output. |
- Returns
- OFTrue if yes, OFFalse if no.
Usage Example:
{
CustomJsonFormat(
const OFBool printMetaInfo = OFTrue,
... bulkDataURIDatabase)
, TheDatabase(bulkDataURIDatabase)
{
}
{
... result = TheDatabase.findBulkDataFor(tag);
if (result.found())
{
uri = result.uri();
return OFTrue;
}
return OFFalse;
}
... TheDatabase;
}
◆ escapeControlCharacters()
static void DcmJsonFormat::escapeControlCharacters |
( |
STD_NAMESPACE ostream & |
out, |
|
|
OFString const & |
value |
|
) |
| |
|
static |
Escapes all forbidden control characters in JSON.
- Parameters
-
out | output stream to which the escaped String is written |
value | String that should be escaped |
◆ indent()
Method to return an indention proxy object for increasing, decreasing or printing indention.
- Returns
- an indention proxy object.
◆ newline()
virtual OFString DcmJsonFormat::newline |
( |
| ) |
|
|
pure virtual |
◆ normalizeDecimalString()
static void DcmJsonFormat::normalizeDecimalString |
( |
OFString & |
value | ) |
|
|
static |
Normalize Decimal String to specific JSON format.
remove leading zeros, except before dot. Example:
00.123 --> 0.123
023.12 --> 23.12
-01.00 --> -1.00
0200 --> 200
.12 --> 0.12
000.1 --> 0.1
- Parameters
-
value | String that should be normalize |
◆ normalizeIntegerString()
static void DcmJsonFormat::normalizeIntegerString |
( |
OFString & |
value | ) |
|
|
static |
Normalize Integer String to specific JSON format.
remove leading zeros, except before dot. Example:
000 --> 0
023 --> 23
-01 --> -1
0200 --> 200
- Parameters
-
value | String that should be normalize |
◆ printBulkDataURIPrefix()
virtual void DcmJsonFormat::printBulkDataURIPrefix |
( |
STD_NAMESPACE ostream & |
out | ) |
|
|
virtual |
Print the Prefix which for JSON BulkDataURI needed with indention and newlines as in the format Variable given.
Example:
- Parameters
-
out | output stream to which the Value prefix is written |
◆ printIndention()
virtual void DcmJsonFormat::printIndention |
( |
STD_NAMESPACE ostream & |
out | ) |
|
|
protectedpure virtual |
◆ printInlineBinaryPrefix()
virtual void DcmJsonFormat::printInlineBinaryPrefix |
( |
STD_NAMESPACE ostream & |
out | ) |
|
|
virtual |
Print the Prefix which for JSON InlineBinary needed with indention and newlines as the format specifies.
Example:
- Parameters
-
out | output stream to which the Value prefix is written |
◆ printNextArrayElementPrefix()
virtual void DcmJsonFormat::printNextArrayElementPrefix |
( |
STD_NAMESPACE ostream & |
out | ) |
|
|
virtual |
Print the prefix for array elements (except the first one), with indention and newlines as the format specifies.
Example:
- Parameters
-
out | output stream to which the Value prefix is written |
◆ printNumberDecimal()
static void DcmJsonFormat::printNumberDecimal |
( |
STD_NAMESPACE ostream & |
out, |
|
|
OFString & |
value |
|
) |
| |
|
static |
Print either null if empty or a Number as normelized IntegerDecimal.
- Parameters
-
out | output stream to which the Value prefix is written |
value | String that should be printed |
◆ printNumberInteger()
static void DcmJsonFormat::printNumberInteger |
( |
STD_NAMESPACE ostream & |
out, |
|
|
OFString & |
value |
|
) |
| |
|
static |
Print either null if empty or a Number as normelized IntegerString.
- Parameters
-
out | output stream to which the Value prefix is written |
value | String that should be printed |
◆ printString()
static void DcmJsonFormat::printString |
( |
STD_NAMESPACE ostream & |
out, |
|
|
const OFString & |
value |
|
) |
| |
|
static |
Prints either null if empty or the string value (with all illegal characters escaped).
- Parameters
-
out | output stream to which the Value prefix is written |
value | String that should be printed |
◆ printValuePrefix()
virtual void DcmJsonFormat::printValuePrefix |
( |
STD_NAMESPACE ostream & |
out | ) |
|
|
virtual |
Print the Prefix which for JSON Values needed with indention and newlines as in the format Variable given.
Example:
- Parameters
-
out | output stream to which the Value prefix is written |
◆ printValueString()
static void DcmJsonFormat::printValueString |
( |
STD_NAMESPACE ostream & |
out, |
|
|
const OFString & |
value |
|
) |
| |
|
static |
Prints either null if empty or a quoted string (with leading and ending quotation marks and all illegal characters escaped).
- Parameters
-
out | output stream to which the Value prefix is written |
value | String that should be printed |
◆ printValueSuffix()
virtual void DcmJsonFormat::printValueSuffix |
( |
STD_NAMESPACE ostream & |
out | ) |
|
|
virtual |
Print the Suffix which for JSON Values needed with indention and newlines as in the format Variable given.
Example:
- Parameters
-
out | output stream to which the Value prefix is written |
◆ space()
virtual OFString DcmJsonFormat::space |
( |
| ) |
|
|
pure virtual |
The documentation for this class was generated from the following file:
- dcmdata/include/dcmtk/dcmdata/dcjson.h