mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-04 11:15:56 +00:00
This change is to improve code coverage (and to simplify #5720 and #5725); there is otherwise no change in functionality. The change adds basic tests for `STInteger` and `STParsedJSON`, so it becomes easier to test smaller changes to the types, as well as removes `STParsedJSONArray`, since it is not used anywhere (including in Clio).
60 lines
2.1 KiB
C++
60 lines
2.1 KiB
C++
//------------------------------------------------------------------------------
|
|
/*
|
|
This file is part of rippled: https://github.com/ripple/rippled
|
|
Copyright (c) 2012, 2013 Ripple Labs Inc.
|
|
|
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
purpose with or without fee is hereby granted, provided that the above
|
|
copyright notice and this permission notice appear in all copies.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
*/
|
|
//==============================================================================
|
|
|
|
#ifndef RIPPLE_PROTOCOL_STPARSEDJSON_H_INCLUDED
|
|
#define RIPPLE_PROTOCOL_STPARSEDJSON_H_INCLUDED
|
|
|
|
#include <xrpl/protocol/STArray.h>
|
|
|
|
#include <optional>
|
|
|
|
namespace ripple {
|
|
|
|
/** Holds the serialized result of parsing an input JSON object.
|
|
This does validation and checking on the provided JSON.
|
|
*/
|
|
class STParsedJSONObject
|
|
{
|
|
public:
|
|
/** Parses and creates an STParsedJSON object.
|
|
The result of the parsing is stored in object and error.
|
|
Exceptions:
|
|
Does not throw.
|
|
@param name The name of the JSON field, used in diagnostics.
|
|
@param json The JSON-RPC to parse.
|
|
*/
|
|
STParsedJSONObject(std::string const& name, Json::Value const& json);
|
|
|
|
STParsedJSONObject() = delete;
|
|
STParsedJSONObject(STParsedJSONObject const&) = delete;
|
|
STParsedJSONObject&
|
|
operator=(STParsedJSONObject const&) = delete;
|
|
~STParsedJSONObject() = default;
|
|
|
|
/** The STObject if the parse was successful. */
|
|
std::optional<STObject> object;
|
|
|
|
/** On failure, an appropriate set of error values. */
|
|
Json::Value error;
|
|
};
|
|
|
|
} // namespace ripple
|
|
|
|
#endif
|