/usr/include/jsonrpccpp/common/procedure.h is in libjsonrpccpp-dev 0.6.0-2build1.
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 | /*************************************************************************
* libjson-rpc-cpp
*************************************************************************
* @file procedure.h
* @date 31.12.2012
* @author Peter Spiess-Knafl <peter.knafl@gmail.com>
* @license See attached LICENSE.txt
************************************************************************/
#ifndef JSONRPC_CPP_PROCEDURE_H_
#define JSONRPC_CPP_PROCEDURE_H_
#include <string>
#include <map>
#include "jsonparser.h"
#include "specification.h"
namespace jsonrpc
{
typedef std::map<std::string, jsontype_t> parameterNameList_t;
typedef std::vector<jsontype_t> parameterPositionList_t;
typedef enum {PARAMS_BY_NAME, PARAMS_BY_POSITION} parameterDeclaration_t;
class Procedure
{
public:
Procedure();
/**
* @brief Constructor for notificaiton with parameters as va_list. The last parameter must be NULL.
* If no parameters are passed, parameters either do not exist, or cannot be checked for type compliance by the library.
* @param name
*/
Procedure(const std::string& name, parameterDeclaration_t paramType, ...);
/**
* @brief Constructor for method with parameters as va_list. The last parameter must be NULL.
* If no parameters are passed, parameters either do not exist, or cannot be checked for type compliance by the library.
* @param name
* @param returntype
*/
Procedure(const std::string& name, parameterDeclaration_t paramType, jsontype_t returntype, ...);
/**
* This method is validating the incoming parameters for each procedure.
* @param parameters - should contain the parameter-object of an valid json-rpc 2.0 request
* @see http://groups.google.com/group/json-rpc/web/json-rpc-2-0
* @return true on successful validation false otherwise.
*
* If the valid parameters are of Type JSON_ARRAY or JSON_OBJECT, they can only be checked for name and not for their structure.
*/
bool ValdiateParameters(const Json::Value ¶meters) const;
//Various get methods.
const parameterNameList_t& GetParameters () const;
procedure_t GetProcedureType () const;
const std::string& GetProcedureName () const;
jsontype_t GetReturnType () const;
parameterDeclaration_t GetParameterDeclarationType () const;
//Various set methods.
void SetProcedureName (const std::string &name);
void SetProcedureType (procedure_t type);
void SetReturnType (jsontype_t type);
void SetParameterDeclarationType (parameterDeclaration_t type);
/**
* @brief AddParameter
* @param name describes the name of the parameter. In case of an positional parameters, this value can be anything.
* @param type describes the defined type for this parameter.
*/
void AddParameter(const std::string& name, jsontype_t type);
bool ValidateNamedParameters (const Json::Value ¶meters) const;
bool ValidatePositionalParameters (const Json::Value ¶meters) const;
private:
/**
* Each Procedure should have a name.
*/
std::string procedureName;
/**
* This map represents all necessary Parameters of each Procedure.
* The string represents the name of each parameter and JsonType the type it should have.
*/
parameterNameList_t parametersName;
/**
* This vector holds all parametertypes by position.
*/
parameterPositionList_t parametersPosition;
/**
* @brief defines whether the procedure is a method or a notification
*/
procedure_t procedureType;
/**
* @brief this field is only valid if procedure is of type method (not notification).
*/
jsontype_t returntype;
/**
* @brief paramDeclaration this field defines if procedure uses named or positional parameters.
*/
parameterDeclaration_t paramDeclaration;
bool ValidateSingleParameter (jsontype_t expectedType, const Json::Value &value) const;
};
} /* namespace jsonrpc */
#endif /* JSONRPC_CPP_PROCEDURE_H_ */
|