mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
For #299, refine code.
This commit is contained in:
parent
62b7204514
commit
f32aab3d92
175 changed files with 15529 additions and 15935 deletions
|
@ -1,32 +1,29 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013-2017 SRS(ossrs)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2013-2017 SRS(ossrs)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef SRS_PROTOCOL_JSON_HPP
|
||||
#define SRS_PROTOCOL_JSON_HPP
|
||||
|
||||
/*
|
||||
#include <srs_protocol_json.hpp>
|
||||
*/
|
||||
#include <srs_core.hpp>
|
||||
|
||||
#include <string>
|
||||
|
@ -68,8 +65,8 @@ class SrsJsonAny
|
|||
{
|
||||
public:
|
||||
char marker;
|
||||
// donot directly create this object,
|
||||
// instead, for examle, use SrsJsonAny::str() to create a concreated one.
|
||||
// donot directly create this object,
|
||||
// instead, for examle, use SrsJsonAny::str() to create a concreated one.
|
||||
protected:
|
||||
SrsJsonAny();
|
||||
public:
|
||||
|
@ -84,40 +81,40 @@ public:
|
|||
virtual bool is_null();
|
||||
public:
|
||||
/**
|
||||
* get the string of any when is_string() indicates true.
|
||||
* user must ensure the type is a string, or assert failed.
|
||||
*/
|
||||
* get the string of any when is_string() indicates true.
|
||||
* user must ensure the type is a string, or assert failed.
|
||||
*/
|
||||
virtual std::string to_str();
|
||||
/**
|
||||
* get the boolean of any when is_boolean() indicates true.
|
||||
* user must ensure the type is a boolean, or assert failed.
|
||||
*/
|
||||
* get the boolean of any when is_boolean() indicates true.
|
||||
* user must ensure the type is a boolean, or assert failed.
|
||||
*/
|
||||
virtual bool to_boolean();
|
||||
/**
|
||||
* get the integer of any when is_integer() indicates true.
|
||||
* user must ensure the type is a integer, or assert failed.
|
||||
*/
|
||||
* get the integer of any when is_integer() indicates true.
|
||||
* user must ensure the type is a integer, or assert failed.
|
||||
*/
|
||||
virtual int64_t to_integer();
|
||||
/**
|
||||
* get the number of any when is_number() indicates true.
|
||||
* user must ensure the type is a number, or assert failed.
|
||||
*/
|
||||
* get the number of any when is_number() indicates true.
|
||||
* user must ensure the type is a number, or assert failed.
|
||||
*/
|
||||
virtual double to_number();
|
||||
/**
|
||||
* get the object of any when is_object() indicates true.
|
||||
* user must ensure the type is a object, or assert failed.
|
||||
*/
|
||||
* get the object of any when is_object() indicates true.
|
||||
* user must ensure the type is a object, or assert failed.
|
||||
*/
|
||||
virtual SrsJsonObject* to_object();
|
||||
/**
|
||||
* get the ecma array of any when is_ecma_array() indicates true.
|
||||
* user must ensure the type is a ecma array, or assert failed.
|
||||
*/
|
||||
* get the ecma array of any when is_ecma_array() indicates true.
|
||||
* user must ensure the type is a ecma array, or assert failed.
|
||||
*/
|
||||
virtual SrsJsonArray* to_array();
|
||||
public:
|
||||
virtual std::string dumps();
|
||||
virtual SrsAmf0Any* to_amf0();
|
||||
public:
|
||||
static SrsJsonAny* str(const char* value = NULL);
|
||||
static SrsJsonAny* str(const char* value = NULL);
|
||||
static SrsJsonAny* boolean(bool value = false);
|
||||
static SrsJsonAny* integer(int64_t value = 0);
|
||||
static SrsJsonAny* number(double value = 0.0);
|
||||
|
@ -126,9 +123,9 @@ public:
|
|||
static SrsJsonArray* array();
|
||||
public:
|
||||
/**
|
||||
* read json tree from str:char*
|
||||
* @return json object. NULL if error.
|
||||
*/
|
||||
* read json tree from str:char*
|
||||
* @return json object. NULL if error.
|
||||
*/
|
||||
static SrsJsonAny* loads(char* str);
|
||||
};
|
||||
|
||||
|
@ -167,7 +164,7 @@ class SrsJsonArray : public SrsJsonAny
|
|||
{
|
||||
private:
|
||||
std::vector<SrsJsonAny*> properties;
|
||||
|
||||
|
||||
private:
|
||||
// use SrsJsonAny::array() to create it.
|
||||
friend class SrsJsonAny;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue