Files
opm-common/opm/parser/eclipse/python/c_inter/cdeck_item.cc
Jørgen Kvalsvik fdb772e075 DeckItem without internal inheritance.
Replaces the internal inheritance + unique_ptr scheme to a flat sum type
similar scheme that uses a tag to determine which operations are legal,
rather than using the indirection itself as a tag.
2016-11-07 12:24:38 +01:00

41 lines
1.3 KiB
C++

#include <opm/parser/eclipse/Deck/DeckItem.hpp>
extern "C" {
int deck_item_get_size( const Opm::DeckItem * item );
int deck_item_get_type( const Opm::DeckItem * item );
int deck_item_iget_int( const Opm::DeckItem * item , int index);
double deck_item_iget_double( const Opm::DeckItem * item , int index);
const char * deck_item_iget_string( const Opm::DeckItem * item , int index);
/*-----------------------------------------------------------------*/
int deck_item_get_size( const Opm::DeckItem * item ) {
return static_cast<int>(item->size());
}
/*
These types must be *manually* syncronized with the values in
the Python module: opm/deck/item_type_enum.py
*/
int deck_item_get_type( const Opm::DeckItem * item ) {
return static_cast< int >( item->getType() );
}
int deck_item_iget_int( const Opm::DeckItem * item , int index) {
return item->get< int >(static_cast<size_t>(index));
}
double deck_item_iget_double( const Opm::DeckItem * item , int index) {
return item->get< double >(static_cast<size_t>(index));
}
const char * deck_item_iget_string( const Opm::DeckItem * item , int index) {
const std::string& string = item->get< std::string >(static_cast<size_t>(index));
return string.c_str();
}
}