Exemplo n.º 1
0
void Property::Value::SetItem(const int index, const Property::Value &value)
{
  switch( GetType() )
  {
    case Property::MAP:
    {
      Property::Map *container = AnyCast<Property::Map>(&(mImpl->mValue));
      if( container && index < static_cast<int>(container->size()) )
      {
        int i = 0;
        for(Property::Map::iterator iter = container->begin(); iter != container->end(); ++iter)
        {
          if(i++ == index)
          {
            iter->second = value;
            break;
          }
        }
      }
    }
    break;

    case Property::ARRAY:
    {
      Property::Array *container = AnyCast<Property::Array>(&(mImpl->mValue));
      if( container && index < static_cast<int>(container->size()) )
      {
        (*container)[index] = value;
      }
    }
    break;

    case Property::NONE:
    case Property::BOOLEAN:
    case Property::FLOAT:
    case Property::INTEGER:
    case Property::UNSIGNED_INTEGER:
    case Property::VECTOR2:
    case Property::VECTOR3:
    case Property::VECTOR4:
    case Property::MATRIX3:
    case Property::MATRIX:
    case Property::RECTANGLE:
    case Property::ROTATION:
    case Property::STRING:
    case Property::TYPE_COUNT:
    {
      DALI_ASSERT_ALWAYS(!"Cannot SetItem on property Type; not a container");
      break;
    }
  }
}
Exemplo n.º 2
0
int Property::Value::GetSize() const
{
  int ret = 0;

  switch(GetType())
  {
    case Property::MAP:
    {
      Property::Map *container = AnyCast<Property::Map>(&(mImpl->mValue));
      if(container)
      {
        ret = container->size();
      }
    }
    break;

    case Property::ARRAY:
    {
      Property::Array *container = AnyCast<Property::Array>(&(mImpl->mValue));
      if(container)
      {
        ret = container->size();
      }
    }
    break;

    case Property::NONE:
    case Property::BOOLEAN:
    case Property::FLOAT:
    case Property::INTEGER:
    case Property::UNSIGNED_INTEGER:
    case Property::VECTOR2:
    case Property::VECTOR3:
    case Property::VECTOR4:
    case Property::MATRIX3:
    case Property::MATRIX:
    case Property::RECTANGLE:
    case Property::ROTATION:
    case Property::STRING:
    case Property::TYPE_COUNT:
    {
      break;
    }

  }

  return ret;
}
Exemplo n.º 3
0
int Property::Value::AppendItem(const Property::Value &value)
{
  DALI_ASSERT_DEBUG(Property::ARRAY == GetType() && "Property type invalid");

  Property::Array *container = AnyCast<Property::Array>(&(mImpl->mValue));

  if(container)
  {
    container->push_back(value);
    return container->size() - 1;
  }
  else
  {
    return -1;
  }

}
Exemplo n.º 4
0
Property::Value& Property::Value::GetItem(const int index) const
{
  switch( GetType() )
  {
    case Property::MAP:
    {
      int i = 0;
      Property::Map *container = AnyCast<Property::Map>(&(mImpl->mValue));

      DALI_ASSERT_DEBUG(container && "Property::Map has no container?");
      if(container)
      {
        DALI_ASSERT_ALWAYS(index < static_cast<int>(container->size()) && "Property array index invalid");
        DALI_ASSERT_ALWAYS(index >= 0 && "Property array index invalid");

        for(Property::Map::iterator iter = container->begin(); iter != container->end(); ++iter)
        {
          if(i++ == index)
          {
            return iter->second;
          }
        }
      }
    }
    break;

    case Property::ARRAY:
    {
      int i = 0;
      Property::Array *container = AnyCast<Property::Array>(&(mImpl->mValue));

      DALI_ASSERT_DEBUG(container && "Property::Map has no container?");
      if(container)
      {
        DALI_ASSERT_ALWAYS(index < static_cast<int>(container->size()) && "Property array index invalid");
        DALI_ASSERT_ALWAYS(index >= 0 && "Property array index invalid");

        for(Property::Array::iterator iter = container->begin(); iter != container->end(); ++iter)
        {
          if(i++ == index)
          {
            return *iter;
          }
        }
      }
    }
    break;

    case Property::NONE:
    case Property::BOOLEAN:
    case Property::FLOAT:
    case Property::INTEGER:
    case Property::UNSIGNED_INTEGER:
    case Property::VECTOR2:
    case Property::VECTOR3:
    case Property::VECTOR4:
    case Property::MATRIX3:
    case Property::MATRIX:
    case Property::RECTANGLE:
    case Property::ROTATION:
    case Property::STRING:
    case Property::TYPE_COUNT:
    {
      DALI_ASSERT_ALWAYS(!"Cannot GetItem on property Type; not a container");
      break;
    }

  } // switch GetType()


  DALI_ASSERT_ALWAYS(!"Property value index not valid");

  // should never return this
  static Property::Value null;
  return null;
}