1
0
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:
Ruben S. Montero 2014-05-02 14:11:36 +02:00
parent 6cecb17f2d
commit 61c3fe95f8
2 changed files with 40 additions and 0 deletions

View File

@ -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
*

View File

@ -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;