class QPanda::OriginCollection¶
Overview¶
Origin Collection A relatively free data collection class for saving data. More…
#include <OriginCollection.h> class OriginCollection { public: // construction OriginCollection(); OriginCollection(const std::string& file_path, bool is_suffix = true); OriginCollection(const OriginCollection& old); // methods template <typename T> void addValue(const std::string& key_name, const T& value); template <typename T> void addValue( const std::string& key_name, const std::vector<T>& value ); void addValue(const std::string& key_name, const std::vector<std::string>& value); void addValue(const std::string& key_name, const std::string& value); void addValue(const std::string& key_name, const char* value); void addValue(const std::string& key_name); OriginCollection& operator = (const std::initializer_list<std::string>& args); OriginCollection& operator = (const std::vector<std::string>& args); OriginCollection& operator = (const OriginCollection& old); template <typename T> void setValueByKey( const std::string& name, const std::initializer_list<T> args ); void setValueByKey(const std::string& name, const std::initializer_list<std::string> args); void setValueByKey(const std::string& name, const std::initializer_list<const char*> args); template <typename T> void setValueByKey( const std::string& name, const std::vector<T>& value ); template <class... ARG> void insertValue(const std::string& key, ARG... arg); template <class... ARG> void insertValue(const int key, ARG... arg); template <class... ARG> void insertValue( const std::vector<std::string>& name_vector, const std::string& key, ARG... args ); template <class... ARG> void insertValue( const std::vector<std::string>& name_vector, const int key, ARG... args ); std::vector<std::string> getValue(const std::string name); std::string getValueByKey(const std::string& key_value); std::string getValueByKey(int key_value); bool open(const std::string& file_name); bool write(); std::string getJsonString(); std::string getFilePath(); std::vector<std::string> getKeyVector(); };
Detailed Documentation¶
Origin Collection A relatively free data collection class for saving data.
Parameters:
| number | The num of key |
Construction¶
OriginCollection()
Construct a new Origin Collection object.
OriginCollection(const std::string& file_path, bool is_suffix = true)
Construct a new Origin Collection Construct a new Origin Collection by file_path.
Parameters:
| file_path | File path |
OriginCollection(const OriginCollection& old)
Construct a new Origin Collection object by other Origin Collection.
Parameters:
| old | target OriginCollection |
Methods¶
template <typename T> void addValue(const std::string& key_name, const T& value)
add value Assign a value to the specified key
Parameters:
| T | value type |
| value_name | Key name |
| num | Key position in json |
| value | key value |
template <typename T> void addValue( const std::string& key_name, const std::vector<T>& value )
add value Assign a value to the specified key
Parameters:
| T | value type |
| value_name | Key name |
| num | Key position in json |
| value | key value |
void addValue( const std::string& key_name, const std::vector<std::string>& value )
add value Assign a value to the specified key
Parameters:
| T | value type |
| value_name | Key name |
| num | Key position in json |
| value | key value |
void addValue(const std::string& key_name, const std::string& value)
add value Set the value corresponding to the key
Parameters:
| value_name | Key name |
| num | Key position in json |
| value | Key value |
void addValue(const std::string& key_name, const char* value)
add value Set the value corresponding to the key
Parameters:
| value_name | Key name |
| num | Key position in json |
| value | Key value |
OriginCollection& operator = (const std::initializer_list<std::string>& args)
operator= Set the key of the object
Parameters:
| args | arg list Key list |
Returns:
OriginCollection& operator = (const std::vector<std::string>& args)
operator= Set the key of the object
Parameters:
| args | arg list Key list |
Returns:
OriginCollection& operator = (const OriginCollection& old)
operator= by other OriginCollection
Parameters:
| old | target OriginCollection |
Returns:
template <typename T> void setValueByKey( const std::string& name, const std::initializer_list<T> args )
Set the Value set value list by key.
Parameters:
| T | args type |
| name | key name |
| args | value array |
void setValueByKey( const std::string& name, const std::initializer_list<std::string> args )
Set the Value set value list by key.
Parameters:
| name | key name |
| args | value array |
void setValueByKey( const std::string& name, const std::initializer_list<const char*> args )
Set the Value set value list by key.
Parameters:
| name | key name |
| args | value array |
template <typename T> void setValueByKey( const std::string& name, const std::vector<T>& value )
Set the Value set vector<T> value by key.
Parameters:
| T | args type |
| name | key name |
| args | value array |
template <class... ARG> void insertValue(const std::string& key, ARG... arg)
insert value Set the value of other properties by the value of the primary key
Parameters:
| ARG | Variable length parameter tparam |
| key | Key value |
| arg | the value of other properties |
template <class... ARG> void insertValue(const int key, ARG... arg)
insert value Set the value of other properties by the value of the primary key
Parameters:
| ARG | Variable length parameter tparam |
| key | Key value |
| arg | the value of other properties |
std::vector<std::string> getValue(const std::string name)
Get value by Key.
Parameters:
| name | Key name |
Returns:
std::vector<std::string> value vector
std::string getValueByKey(const std::string& key_value)
Get value by primary Key value.
Parameters:
| key_value | primary Key value |
Returns:
std::string
std::string getValueByKey(int key_value)
Get value by primary Key value.
Parameters:
| key_value | primary Key value |
Returns:
std::string
bool open(const std::string& file_name)
open Read the json file of the specified path
Parameters:
| file_name | file path |
Returns:
true open success
false open fail
bool write()
write Write json file
Returns:
true Write success
false Write fail
std::string getJsonString()
Get the Json String Get object json string.
Returns:
std::string
std::string getFilePath()
Get the File Path.
Returns:
std::string