示例#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;
    }
  }
}
示例#2
0
const std::string& Property::Value::GetKey(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)
      {
        if(0 <= index && index < static_cast<int>(container->size()))
        {
          for(Property::Map::iterator iter = container->begin(); iter != container->end(); ++iter)
          {
            if(i++ == index)
            {
              return iter->first;
            }
          }
        }
      }
    }
    break;
    case Property::NONE:
    case Property::ARRAY:
    case Property::BOOLEAN:
    case Property::FLOAT:
    case Property::UNSIGNED_INTEGER:
    case Property::INTEGER:
    case Property::VECTOR2:
    case Property::VECTOR3:
    case Property::VECTOR4:
    case Property::MATRIX:
    case Property::MATRIX3:
    case Property::RECTANGLE:
    case Property::ROTATION:
    case Property::STRING:
    case Property::TYPE_COUNT:
    {
      break;
    }
  }


  // should never return this
  static std::string null;
  return null;
}
示例#3
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;
}
示例#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;
}