summaryrefslogtreecommitdiffstats
path: root/src/rpc-server/trex_rpc_cmd.cpp
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2016-02-16 07:22:01 -0500
committerimarom <imarom@cisco.com>2016-02-16 07:22:01 -0500
commit0bc8b0acfb2d2e158c7b41bc398aef3137087859 (patch)
tree89287366dbae72b45f5efc043ba5e05a692c2a58 /src/rpc-server/trex_rpc_cmd.cpp
parent8f6067d8738fa77a147955ee208ece8dea198111 (diff)
added support for default fields at the JSON RPC server
Diffstat (limited to 'src/rpc-server/trex_rpc_cmd.cpp')
-rw-r--r--src/rpc-server/trex_rpc_cmd.cpp97
1 files changed, 1 insertions, 96 deletions
diff --git a/src/rpc-server/trex_rpc_cmd.cpp b/src/rpc-server/trex_rpc_cmd.cpp
index aea7980b..f8779860 100644
--- a/src/rpc-server/trex_rpc_cmd.cpp
+++ b/src/rpc-server/trex_rpc_cmd.cpp
@@ -145,102 +145,6 @@ TrexRpcCommand::json_type_to_name(const Json::Value &value) {
}
-uint8_t
-TrexRpcCommand::parse_byte(const Json::Value &parent, const std::string &name, Json::Value &result) {
- check_field_type(parent, name, FIELD_TYPE_BYTE, result);
- return parent[name].asUInt();
-}
-
-uint8_t
-TrexRpcCommand::parse_byte(const Json::Value &parent, int index, Json::Value &result) {
- check_field_type(parent, index, FIELD_TYPE_BYTE, result);
- return parent[index].asUInt();
-}
-
-uint16_t
-TrexRpcCommand::parse_uint16(const Json::Value &parent, const std::string &name, Json::Value &result) {
- check_field_type(parent, name, FIELD_TYPE_UINT16, result);
- return parent[name].asUInt();
-}
-
-uint16_t
-TrexRpcCommand::parse_uint16(const Json::Value &parent, int index, Json::Value &result) {
- check_field_type(parent, index, FIELD_TYPE_UINT16, result);
- return parent[index].asUInt();
-}
-
-uint32_t
-TrexRpcCommand::parse_uint32(const Json::Value &parent, const std::string &name, Json::Value &result) {
- check_field_type(parent, name, FIELD_TYPE_UINT32, result);
- return parent[name].asUInt();
-}
-
-uint32_t
-TrexRpcCommand::parse_uint32(const Json::Value &parent, int index, Json::Value &result) {
- check_field_type(parent, index, FIELD_TYPE_UINT32, result);
- return parent[index].asUInt();
-}
-
-uint64_t
-TrexRpcCommand::parse_uint64(const Json::Value &parent, const std::string &name, Json::Value &result) {
- check_field_type(parent, name, FIELD_TYPE_UINT64, result);
- return parent[name].asUInt64();
-}
-
-uint64_t
-TrexRpcCommand::parse_uint64(const Json::Value &parent, int index, Json::Value &result) {
- check_field_type(parent, index, FIELD_TYPE_UINT64, result);
- return parent[index].asUInt64();
-}
-
-int
-TrexRpcCommand::parse_int(const Json::Value &parent, const std::string &name, Json::Value &result) {
- check_field_type(parent, name, FIELD_TYPE_INT, result);
- return parent[name].asInt();
-}
-
-bool
-TrexRpcCommand::parse_bool(const Json::Value &parent, const std::string &name, Json::Value &result) {
- check_field_type(parent, name, FIELD_TYPE_BOOL, result);
- return parent[name].asBool();
-}
-
-double
-TrexRpcCommand::parse_double(const Json::Value &parent, const std::string &name, Json::Value &result) {
- check_field_type(parent, name, FIELD_TYPE_DOUBLE, result);
- return parent[name].asDouble();
-}
-
-const std::string
-TrexRpcCommand::parse_string(const Json::Value &parent, const std::string &name, Json::Value &result) {
- check_field_type(parent, name, FIELD_TYPE_STR, result);
- return parent[name].asString();
-}
-
-/**
- * object version
- */
-const Json::Value &
-TrexRpcCommand::parse_object(const Json::Value &parent, const std::string &name, Json::Value &result) {
- check_field_type(parent, name, FIELD_TYPE_OBJ, result);
- return parent[name];
-}
-
-/**
- * index version
- */
-const Json::Value &
-TrexRpcCommand::parse_object(const Json::Value &parent, int index, Json::Value &result) {
- check_field_type(parent, index, FIELD_TYPE_OBJ, result);
- return parent[index];
-}
-
-const Json::Value &
-TrexRpcCommand::parse_array(const Json::Value &parent, const std::string &name, Json::Value &result) {
- check_field_type(parent, name, FIELD_TYPE_ARRAY, result);
- return parent[name];
-}
-
/**
* for index element (array)
*/
@@ -269,6 +173,7 @@ TrexRpcCommand::check_field_type(const Json::Value &parent, const std::string &n
const Json::Value &field = parent[name];
check_field_type_common(field, name, type, result);
}
+
void
TrexRpcCommand::check_field_type_common(const Json::Value &field, const std::string &name, field_type_e type, Json::Value &result) {
std::stringstream ss;