Kodi Documentation 22.0
Kodi is an open source media player and entertainment hub.
Loading...
Searching...
No Matches
JSONRPC::CJSONUtils Class Reference

Helper class containing utility methods to handle json rpc method calls. More...

#include <JSONUtils.h>

Inheritance diagram for JSONRPC::CJSONUtils:
JSONRPC::CAddonsOperations JSONRPC::CFavouritesOperations JSONRPC::CFileItemHandler JSONRPC::CJSONServiceDescription JSONRPC::JSONSchemaTypeDefinition JSONRPC::JsonRpcMethod JSONRPC::CApplicationOperations JSONRPC::CAudioLibrary JSONRPC::CFileOperations JSONRPC::CPVROperations JSONRPC::CPlayerOperations JSONRPC::CPlaylistOperations JSONRPC::CProfilesOperations JSONRPC::CVideoLibrary

Static Public Member Functions

static void MillisecondsToTimeObject (int time, CVariant &result)
 

Static Protected Member Functions

static void HandleLimits (const CVariant &parameterObject, CVariant &result, int size, int &start, int &end)
 
static bool ParseSorting (const CVariant &parameterObject, SortBy &sortBy, SortOrder &sortOrder, SortAttribute &sortAttributes)
 
static void ParseLimits (const CVariant &parameterObject, int &limitStart, int &limitEnd)
 
static bool ParameterExists (const CVariant &parameterObject, const std::string &key, unsigned int position)
 Checks if the given object contains a parameter.
 
static bool IsValueMember (const CVariant &value, const std::string &key)
 Checks if the given object contains a value with the given key.
 
static CVariant GetParameter (const CVariant &parameterObject, const std::string &key, unsigned int position)
 Returns the json value of a parameter.
 
static CVariant GetParameter (const CVariant &parameterObject, const std::string &key, unsigned int position, const CVariant &fallback)
 Returns the json value of a parameter or the given default value.
 
static std::string GetString (const CVariant &value, const char *defaultValue)
 Returns the given json value as a string.
 
static TransportLayerCapability StringToTransportLayer (const std::string &transport)
 Returns a TransportLayerCapability value of the given string representation.
 
static JSONSchemaType StringToSchemaValueType (const std::string &valueType)
 Returns a JSONSchemaType value for the given string representation.
 
static std::string SchemaValueTypeToString (JSONSchemaType valueType)
 Returns a string representation for the given JSONSchemaType.
 
static void SchemaValueTypeToJson (JSONSchemaType valueType, CVariant &jsonObject)
 Converts the given json schema type into a json object.
 
static const char * ValueTypeToString (CVariant::VariantType valueType)
 
static bool IsParameterType (const CVariant &parameterObject, const char *key, unsigned int position, JSONSchemaType valueType)
 Checks if the parameter with the given name or at the given position is of a certain type.
 
static bool IsType (const CVariant &value, JSONSchemaType valueType)
 Checks if the given json value is of the given type.
 
static void SetDefaultValue (CVariant &value, JSONSchemaType valueType)
 Sets the value of the given json value to the default value of the given type.
 
static bool HasType (JSONSchemaType typeObject, JSONSchemaType type)
 
static bool ParameterNotNull (const CVariant &parameterObject, const std::string &key)
 
static void CopyStringArray (const CVariant &jsonStringArray, std::vector< std::string > &stringArray)
 Copies the values from the jsonStringArray to the stringArray. stringArray is cleared.
 
static void SetFromDBDate (const CVariant &jsonDate, CDateTime &date)
 
static void SetFromDBDateTime (const CVariant &jsonDate, CDateTime &date)
 
static bool GetXspFiltering (const std::string &type, const CVariant &filter, std::string &xsp)
 

Detailed Description

Helper class containing utility methods to handle json rpc method calls.

Member Function Documentation

◆ CopyStringArray()

static void JSONRPC::CJSONUtils::CopyStringArray ( const CVariant & jsonStringArray,
std::vector< std::string > & stringArray )
inlinestaticprotected

Copies the values from the jsonStringArray to the stringArray. stringArray is cleared.

Parameters
jsonStringArrayJSON object representing a string array
stringArrayString array where the values are copied into (cleared)

◆ GetParameter() [1/2]

static CVariant JSONRPC::CJSONUtils::GetParameter ( const CVariant & parameterObject,
const std::string & key,
unsigned int position )
inlinestaticprotected

Returns the json value of a parameter.

Parameters
parameterObjectObject containing all provided parameters
keyPossible name of the parameter
positionPossible position of the parameter
Returns
Json value of the parameter with the given name or at the given position

Returns the value of the parameter with the given key (if the given object is not an array) or of the parameter at the given position (if the given object is an array).

◆ GetParameter() [2/2]

static CVariant JSONRPC::CJSONUtils::GetParameter ( const CVariant & parameterObject,
const std::string & key,
unsigned int position,
const CVariant & fallback )
inlinestaticprotected

Returns the json value of a parameter or the given default value.

Parameters
parameterObjectObject containing all provided parameters
keyPossible name of the parameter
positionPossible position of the parameter
fallbackDefault value of the parameter
Returns
Json value of the parameter with the given name or at the given position or the default value if the parameter does not exist

Returns the value of the parameter with the given key (if the given object is not an array) or of the parameter at the given position (if the given object is an array). If the parameter does not exist the given default value is returned.

◆ GetString()

static std::string JSONRPC::CJSONUtils::GetString ( const CVariant & value,
const char * defaultValue )
inlinestaticprotected

Returns the given json value as a string.

Parameters
valueJson value to convert to a string
defaultValueDefault string value
Returns
String value of the given json value or the default value if the given json value is no string

◆ GetXspFiltering()

static bool JSONRPC::CJSONUtils::GetXspFiltering ( const std::string & type,
const CVariant & filter,
std::string & xsp )
inlinestaticprotected

◆ HandleLimits()

static void JSONRPC::CJSONUtils::HandleLimits ( const CVariant & parameterObject,
CVariant & result,
int size,
int & start,
int & end )
inlinestaticprotected

◆ HasType()

static bool JSONRPC::CJSONUtils::HasType ( JSONSchemaType typeObject,
JSONSchemaType type )
inlinestaticprotected

◆ IsParameterType()

static bool JSONRPC::CJSONUtils::IsParameterType ( const CVariant & parameterObject,
const char * key,
unsigned int position,
JSONSchemaType valueType )
inlinestaticprotected

Checks if the parameter with the given name or at the given position is of a certain type.

Parameters
parameterObjectObject containing all provided parameters
keyPossible name of the parameter
positionPossible position of the parameter
valueTypeExpected type of the parameter
Returns
True if the specific parameter is of the given type otherwise false

◆ IsType()

static bool JSONRPC::CJSONUtils::IsType ( const CVariant & value,
JSONSchemaType valueType )
inlinestaticprotected

Checks if the given json value is of the given type.

Parameters
valueJson value to check
valueTypeExpected type of the json value
Returns
True if the given json value is of the given type otherwise false

◆ IsValueMember()

static bool JSONRPC::CJSONUtils::IsValueMember ( const CVariant & value,
const std::string & key )
inlinestaticprotected

Checks if the given object contains a value with the given key.

Parameters
valueValue to check for the member
keyKey of the member to check for
Returns
True if the given object contains a member with the given key otherwise false

◆ MillisecondsToTimeObject()

static void JSONRPC::CJSONUtils::MillisecondsToTimeObject ( int time,
CVariant & result )
inlinestatic

◆ ParameterExists()

static bool JSONRPC::CJSONUtils::ParameterExists ( const CVariant & parameterObject,
const std::string & key,
unsigned int position )
inlinestaticprotected

Checks if the given object contains a parameter.

Parameters
parameterObjectObject to check for a parameter
keyPossible name of the parameter
positionPossible position of the parameter
Returns
True if the parameter is available otherwise false

Checks the given object for a parameter with the given key (if the given object is not an array) or for a parameter at the given position (if the given object is an array).

◆ ParameterNotNull()

static bool JSONRPC::CJSONUtils::ParameterNotNull ( const CVariant & parameterObject,
const std::string & key )
inlinestaticprotected

◆ ParseLimits()

static void JSONRPC::CJSONUtils::ParseLimits ( const CVariant & parameterObject,
int & limitStart,
int & limitEnd )
inlinestaticprotected

◆ ParseSorting()

static bool JSONRPC::CJSONUtils::ParseSorting ( const CVariant & parameterObject,
SortBy & sortBy,
SortOrder & sortOrder,
SortAttribute & sortAttributes )
inlinestaticprotected

◆ SchemaValueTypeToJson()

static void JSONRPC::CJSONUtils::SchemaValueTypeToJson ( JSONSchemaType valueType,
CVariant & jsonObject )
inlinestaticprotected

Converts the given json schema type into a json object.

Parameters
valueTyejson schema type(s)
jsonObjectjson object into which the json schema type(s) are stored

◆ SchemaValueTypeToString()

static std::string JSONRPC::CJSONUtils::SchemaValueTypeToString ( JSONSchemaType valueType)
inlinestaticprotected

Returns a string representation for the given JSONSchemaType.

Parameters
valueTypeSpecific JSONSchemaType
Returns
String representation of the given JSONSchemaType

◆ SetDefaultValue()

static void JSONRPC::CJSONUtils::SetDefaultValue ( CVariant & value,
JSONSchemaType valueType )
inlinestaticprotected

Sets the value of the given json value to the default value of the given type.

Parameters
valueJson value to be set
valueTypeType of the default value

◆ SetFromDBDate()

void JSONRPC::CJSONUtils::SetFromDBDate ( const CVariant & jsonDate,
CDateTime & date )
staticprotected

◆ SetFromDBDateTime()

void JSONRPC::CJSONUtils::SetFromDBDateTime ( const CVariant & jsonDate,
CDateTime & date )
staticprotected

◆ StringToSchemaValueType()

static JSONSchemaType JSONRPC::CJSONUtils::StringToSchemaValueType ( const std::string & valueType)
inlinestaticprotected

Returns a JSONSchemaType value for the given string representation.

Parameters
valueTypeString representation of the JSONSchemaType
Returns
JSONSchemaType value of the given string representation

◆ StringToTransportLayer()

static TransportLayerCapability JSONRPC::CJSONUtils::StringToTransportLayer ( const std::string & transport)
inlinestaticprotected

Returns a TransportLayerCapability value of the given string representation.

Parameters
transportString representation of the TransportLayerCapability
Returns
TransportLayerCapability value of the given string representation

◆ ValueTypeToString()

static const char * JSONRPC::CJSONUtils::ValueTypeToString ( CVariant::VariantType valueType)
inlinestaticprotected

The documentation for this class was generated from the following files: