FarFile^ PanelFileCollection::default::get(int index)
{
	if (index < 0 || index >= _Count)
		throw gcnew IndexOutOfRangeException("Invalid panel item index.");

	return _Panel->GetFile(index, _Type);
}
Exemple #2
0
void collection_get_primitive(Collection* collection, size_t ndx, PrimitiveValue& value, NativeException::Marshallable& ex)
{
    handle_errors(ex, [&]() {
        const size_t count = collection->size();
        if (ndx >= count)
            throw IndexOutOfRangeException("Get from Collection", ndx, count);
        
        value.has_value = true;
        switch (value.type) {
            case realm::PropertyType::Bool:
                value.value.bool_value = collection->template
                get<bool>(ndx);
                break;
            case realm::PropertyType::Bool | realm::PropertyType::Nullable: {
                auto result = collection->template get<Optional<bool>>(ndx);
                value.has_value = !!result;
                value.value.bool_value = result.value_or(false);
                break;
            }
            case realm::PropertyType::Int:
                value.value.int_value = collection->template get<int64_t>(ndx);
                break;
            case realm::PropertyType::Int | realm::PropertyType::Nullable: {
                auto result = collection->template get<Optional<int64_t>>(ndx);
                value.has_value = !!result;
                value.value.int_value = result.value_or(0);
                break;
            }
            case realm::PropertyType::Float:
                value.value.float_value = collection->template get<float>(ndx);
                break;
            case realm::PropertyType::Float | realm::PropertyType::Nullable: {
                auto result = collection->template get<Optional<float>>(ndx);
                value.has_value = !!result;
                value.value.float_value = result.value_or((float)0);
                break;
            }
            case realm::PropertyType::Double:
                value.value.double_value = collection->template get<double>(ndx);
                break;
            case realm::PropertyType::Double | realm::PropertyType::Nullable: {
                auto result = collection->template get<Optional<double>>(ndx);
                value.has_value = !!result;
                value.value.double_value = result.value_or((double)0);
                break;
            }
            case realm::PropertyType::Date:
                value.value.int_value = to_ticks(collection->template get<Timestamp>(ndx));
                break;
            case realm::PropertyType::Date | realm::PropertyType::Nullable: {
                auto result = collection->template get<Timestamp>(ndx);
                value.has_value = !result.is_null();
                value.value.int_value = result.is_null() ? 0 : to_ticks(result);
                break;
            }
            default:
                REALM_UNREACHABLE();
        }
    });
}
Exemple #3
0
   /// <summary>Find item data by index.</summary>
   /// <param name="index">Zero-based index.</param>
   /// <returns></returns>
   /// <exception cref="Logic::IndexOutOfRangeException">Invalid index</exception>
   DualComboBox::ItemData* DualComboBox::FindItem(UINT index) const
   {
      // Validate index
      if (index >= (UINT)GetCount())
         throw IndexOutOfRangeException(HERE, index, GetCount());

      // Lookup item
      return reinterpret_cast<ItemData*>(GetItemData(index));
   }
Exemple #4
0
inline T get(Collection* collection, size_t ndx, NativeException::Marshallable& ex)
{
    return handle_errors(ex, [&]() {
        const size_t count = collection->size();
        if (ndx >= count)
            throw IndexOutOfRangeException("Get from RealmList", ndx, count);
        
        return collection->template get<T>(ndx);
    });
}
Exemple #5
0
bitset& bitset::operator<<=(size_t n)
{
    if (n >= this->size()) throw IndexOutOfRangeException();

    for (unsigned int i = 0; i < n; i++)
    {
        bitset::bit last;
        bits.erase(bits.begin());
        bits.push_back(last);
    }
    return *this;
}
sf::IntRect Tileset::getTile(int num)
{
	if (num > 0 && num <= items)
	{
		int row = (num - 1) / items_per_row;
		int col = (num - 1) % items_per_row;
		return sf::IntRect(sf::Vector2i(col * tile_size.x, row * tile_size.y), tile_size);
	}
	else
	{
		throw IndexOutOfRangeException(name, num);
	}
}
      /// <summary>Called for each occurrence of {aaa} markers</summary>
      /// <param name="match">The match.</param>
      /// <returns>Replacement text</returns>
      /// <exception cref="Logic::IndexOutOfRangeException">Parameter does not exist</exception>
      /// <exception cref="Logic::PageNotFoundException">Page does not exist</exception>
      /// <exception cref="Logic::StringNotFoundException">String does not exist</exception>
      wstring  DescriptionParser::onParameterMarker(wsmatch& match, CommandSyntaxRef cmd)
      {
         UINT index = _wtoi( match[1].str().c_str() );

         // Verify index
         if (index > cmd.Parameters.size())
            throw IndexOutOfRangeException(HERE, index, cmd.Parameters.size());

         // Lookup type name
         wstring type = StringLib.Find(KnownPage::PARAMETER_TYPES, (UINT)cmd.Parameters[index].Type).Text;

         // Format appropriately
         return VString(L"{PARAMETER:%s}", type.c_str());
      }
Exemple #8
0
const T& Array<T>::operator[](const int index) const{
	if (index >= size || index < 0){
		throw IndexOutOfRangeException();
	}
	return ptr_to_data[index];
}