mirror of
https://github.com/pocoproject/poco.git
synced 2025-04-02 09:49:48 +02:00
add toString()
This commit is contained in:
parent
26c1131053
commit
d0ff7ccf7c
@ -510,12 +510,30 @@ public:
|
|||||||
bool isString() const;
|
bool isString() const;
|
||||||
/// Returns true if stored value is std::string.
|
/// Returns true if stored value is std::string.
|
||||||
|
|
||||||
|
std::string toString() const
|
||||||
|
/// Returns the stored value as string.
|
||||||
|
{
|
||||||
|
VarHolder* pHolder = content();
|
||||||
|
|
||||||
|
if (!pHolder)
|
||||||
|
throw InvalidAccessException("Can not convert empty value.");
|
||||||
|
|
||||||
|
if (typeid(std::string) == pHolder->type())
|
||||||
|
return extract<std::string>();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::string result;
|
||||||
|
pHolder->convert(result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static Var parse(const std::string& val);
|
static Var parse(const std::string& val);
|
||||||
/// Parses the string which must be in JSON format
|
/// Parses the string which must be in JSON format
|
||||||
|
|
||||||
static std::string toString(const Var& any);
|
static std::string toString(const Var& var);
|
||||||
/// Converts the Var to a string in JSON format. Note that toString will return
|
/// Converts the Var to a string in JSON format. Note that toString(const Var&) will return
|
||||||
/// a different result than any.convert<std::string>()!
|
/// a different result than Var::convert<std::string>() and Var::toString()!
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static Var parse(const std::string& val, std::string::size_type& offset);
|
static Var parse(const std::string& val, std::string::size_type& offset);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user