/usr/include/Poco/JSON/PrintHandler.h is in libpoco-dev 1.8.0.1-1ubuntu4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | //
// PrintHandler.h
//
// Library: JSON
// Package: JSON
// Module: PrintHandler
//
// Definition of the PrintHandler class.
//
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef JSON_PrintHandler_INCLUDED
#define JSON_PrintHandler_INCLUDED
#include "Poco/JSON/JSON.h"
#include "Poco/JSON/Handler.h"
namespace Poco {
namespace JSON {
class JSON_API PrintHandler: public Handler
/// PrintHandler formats and prints the JSON object
/// to either user-provided std::ostream or standard output.
/// If indent is zero, the output is a condensed JSON string,
/// otherwise, the proper indentation is applied to elements.
{
public:
typedef SharedPtr<PrintHandler> Ptr;
static const unsigned JSON_PRINT_FLAT = 0;
PrintHandler(unsigned indent = 0);
/// Creates the PrintHandler.
PrintHandler(std::ostream& out, unsigned indent = 0);
/// Creates the PrintHandler.
~PrintHandler();
/// Destroys the PrintHandler.
void reset();
/// Resets the handler state.
void startObject();
/// The parser has read a '{'; a new object is started.
/// If indent is greater than zero, a newline will be appended.
void endObject();
/// The parser has read a '}'; the object is closed.
void startArray();
/// The parser has read a [; a new array will be started.
/// If indent is greater than zero, a newline will be appended.
void endArray();
/// The parser has read a ]; the array is closed.
void key(const std::string& k);
/// A key of an object is read; it will be written to the output,
/// followed by a ':'. If indent is greater than zero, the colon
/// is padded by a space before and after.
void null();
/// A null value is read; "null" will be written to the output.
void value(int v);
/// An integer value is read.
void value(unsigned v);
/// An unsigned value is read. This will only be triggered if the
/// value cannot fit into a signed int.
#if defined(POCO_HAVE_INT64)
void value(Int64 v);
/// A 64-bit integer value is read; it will be written to the output.
void value(UInt64 v);
/// An unsigned 64-bit integer value is read; it will be written to the output.
#endif
void value(const std::string& value);
/// A string value is read; it will be formatted and written to the output.
void value(double d);
/// A double value is read; it will be written to the output.
void value(bool b);
/// A boolean value is read; it will be written to the output.
void comma();
/// A comma is read; it will be written to the output as "true" or "false".
void setIndent(unsigned indent);
/// Sets indentation.
private:
const char* endLine() const;
unsigned indent();
bool printFlat() const;
void arrayValue();
bool array() const;
std::ostream& _out;
unsigned _indent;
std::string _tab;
int _array;
bool _objStart;
};
//
// inlines
//
inline void PrintHandler::setIndent(unsigned indent)
{
_indent = indent;
}
inline bool PrintHandler::array() const
{
return _array > 0;
}
} } // namespace Poco::JSON
#endif // JSON_PrintHandler_INCLUDED
|