mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-23 17:33:56 +03:00
feature #2858: Convert to unsigned int from vector attributes
This commit is contained in:
parent
6cecb17f2d
commit
61c3fe95f8
@ -265,6 +265,16 @@ public:
|
||||
*/
|
||||
int vector_value(const char *name, int& value) const;
|
||||
|
||||
/**
|
||||
* Returns the unsigned integer value
|
||||
*
|
||||
* @param name Name of the attribute
|
||||
* @param value Integer value
|
||||
*
|
||||
* @return 0 on success, -1 otherwise
|
||||
*/
|
||||
int vector_value(const char *name, unsigned int& value) const;
|
||||
|
||||
/**
|
||||
* Returns the long long value
|
||||
*
|
||||
|
@ -281,6 +281,36 @@ int VectorAttribute::vector_value(const char *name, int & value) const
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int VectorAttribute::vector_value(const char *name, unsigned int & value) const
|
||||
{
|
||||
map<string,string>::const_iterator it;
|
||||
|
||||
it = attribute_value.find(name);
|
||||
|
||||
if ( it == attribute_value.end() )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( it->second.empty() )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
istringstream iss(it->second);
|
||||
iss >> value;
|
||||
|
||||
if (iss.fail() || !iss.eof())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int VectorAttribute::vector_value(const char *name, long long& value) const
|
||||
{
|
||||
map<string,string>::const_iterator it;
|
||||
|
Loading…
Reference in New Issue
Block a user