cgv
|
#include <component_format.h>
Public Member Functions | |
component_format (const std::string &description) | |
construct from description string, see set_component_format for docu More... | |
bool | set_component_format (const std::string &description) |
set the component format from a description string More... | |
void | set_components (const std::string &_components) |
comma separated list of component descriptors, for example "R,G,B" | |
component_format (TypeId _component_type=TI_UNDEF, const std::string &_component_name_list="", unsigned int align=1, unsigned int d0=0, unsigned int d1=0, unsigned int d2=0, unsigned int d3=0) | |
construct packed component format from component type, component sequence, and common component bit depth More... | |
component_format (TypeId _component_type, ComponentFormat cf, unsigned int align=1, unsigned int d0=0, unsigned int d1=0, unsigned int d2=0, unsigned int d3=0) | |
construct component format from component type, standard component format, component alignment and bit depths for packed formats | |
void | set_integer_interpretation (ComponentIntegerInterpretation cii) |
set the integer interpretation | |
ComponentIntegerInterpretation | get_integer_interpretation () const |
return current integer interpretation | |
template<typename T > | |
T | get (int ci, const void *ptr) const |
constant access to the i-th component stored at the given location | |
template<typename T > | |
bool | set (int ci, void *ptr, const T &v) const |
write access to the i-th component, return whether write was successful | |
bool | empty () const |
return whether the component format is defined | |
void | clear () |
clear the component format | |
const packing_info & | get_packing_info () const |
return the packing info by simple conversion of the this pointer | |
void | set_packing_info (const packing_info &pi) |
set packing info by simply assigning to a converted this pointer | |
unsigned int | get_nr_components () const |
return the number of components More... | |
unsigned int | get_component_index (const std::string &name) const |
return the index of a component given by name or -1 if not found | |
std::string | get_component_name (unsigned int i) const |
return the name of the component with index i | |
ComponentFormat | get_standard_component_format () const |
return whether the component format is one of the standard formats | |
void | set_component_names (const std::string &_component_name_list) |
set component names from a comma or colon separated list of names | |
void | set_component_format (ComponentFormat _cf) |
set the component names from a standard component format More... | |
TypeId | get_component_type () const |
return the component type | |
void | set_component_type (TypeId _type_id) |
set the component type | |
unsigned int | get_entry_size () const |
return the size of one entry of components in bytes More... | |
bool | operator== (const component_format &cf) const |
comparison between component formats | |
bool | operator!= (const component_format &cf) const |
comparison between component formats | |
unsigned int | get_bit_depth (unsigned int ci) const |
return the bit depth of the ci-th component | |
void | set_bit_depth (unsigned int ci, unsigned int depth) |
set the bit depth of the ci-th component | |
bool | is_packing () const |
return whether packing is enabled | |
void | set_packing (bool enable=true) |
set the packing flag | |
unsigned int | get_component_alignment () const |
return the component alignment in bits in the packed case and in bytes in the unpacked case | |
void | set_component_alignment (unsigned int a) |
set the component alignment in bits in the packed case and in bytes in the unpacked case | |
int | get_signed (unsigned int ci, const void *ptr) const |
return the ci-th component of the data entry pointed to by the given pointer of a signed packed component | |
unsigned int | get_unsigned (unsigned int ci, const void *ptr) const |
return the ci-th component of the data entry pointed to by the given pointer of an unsigned packed component | |
bool | set_signed (unsigned int ci, void *ptr, int v) const |
set the ci-th component of the data entry pointed to by the given pointer of a signed packed component | |
bool | set_unsigned (unsigned int ci, void *ptr, unsigned int v) const |
set the ci-th component of the data entry pointed to by the given pointer of an unsigned packed component | |
bool | operator== (const packing_info &pi) const |
equal comparison | |
bool | operator!= (const packing_info &pi) const |
unequal comparison | |
Static Public Member Functions | |
static const std::string & | get_last_error () |
returns an error string after parsing of description string has failed | |
static unsigned int | align (unsigned int v, unsigned int a) |
return the next integer larger or equal to v which is dividable by a | |
Protected Member Functions | |
void | extract_components () |
extract components from component string More... | |
Protected Attributes | |
TypeId | component_type |
store the type id of the component type | |
ComponentIntegerInterpretation | component_interpretation |
interpretation of integer typed components | |
std::string | component_string |
store all component names in one string separated with 0-chars | |
std::vector< unsigned short > | component_positions |
store the position of each component in the component string | |
Static Protected Attributes | |
static std::string | last_error |
store the last error that appeared during parsing of a description | |
Friends | |
FRIEND_MEMBER_API std::ostream & | operator<< (std::ostream &os, const component_format &cf) |
define stream out operator More... | |
the component format inherits the information of a packing_info and adds information on the component type, which components are present in the data and in which order they appear
|
explicit |
construct from description string, see set_component_format for docu
construct from description string
cgv::data::component_format::component_format | ( | TypeId | _component_type = TI_UNDEF , |
const std::string & | _component_name_list = "" , |
||
unsigned int | align = 1 , |
||
unsigned int | d0 = 0 , |
||
unsigned int | d1 = 0 , |
||
unsigned int | d2 = 0 , |
||
unsigned int | d3 = 0 |
||
) |
construct packed component format from component type, component sequence, and common component bit depth
construct component format from component type, comma or colon separated list of component names, component alignment and bit depths for packed formats
|
protected |
extract components from component string
extract component_positions from component string
unsigned int cgv::data::component_format::get_entry_size | ( | ) | const |
return the size of one entry of components in bytes
return the size of one entry of component_positions in bytes
unsigned int cgv::data::component_format::get_nr_components | ( | ) | const |
return the number of components
return the number of component_positions
void cgv::data::component_format::set_component_format | ( | ComponentFormat | _cf | ) |
set the component names from a standard component format
set the component names from a given component format
bool cgv::data::component_format::set_component_format | ( | const std::string & | description | ) |
set the component format from a description string
set component format from description string, which has the following syntax. If a parse error arises, return false and set the static last_error member, which can be queried with get_last_error():
component_format <- [type] [attributes] '[' component [',' component]* ']' component <- component_name [attributes] attributes <- [':' bit_depth]['|' alignment] type <- "undef" | "bool" | "int8" | "int16" | "int32" | "int64" | "uint8" | "uint16" | "uint32" | "uint64" | "sint8" | "sint16" | "sint32" | "sint64" | // same as int* types but in snorm interpretation "_int8" | "_int16" | "_int32" | "_int64" | "_uint8" | "_uint16" | "_uint32" | "_uint64" | // same as [u]int* but in integer interpretation "flt16" | "flt32" | "flt64" | "string" component_name : string ... name of component, i.e. "R", "Cb", "px", ... bit_depth : unsigned int ... number of bits used to represent a component alignment : unsigned int ... number of bits to which a component is aligned
Some examples of valid component format description strings:
"uint8:3|4[R,G,B,A]"
... four components represented as unsigned integers with no more than 8 bits. Actually, each component is stored with 3 bits and aligned to a bit index which is a multiple of 4"uint8[R:5,G:6,B:5]"
... three components packed into 16 bits with 5 bits for R, 6 for G and 5 for B."sint8[R,G]"
... two component format of type int8 in snorm interpretation,"_uint16[R]"
... one component format of type uint16 in integer interpretation,"flt32[px,py]"
... two components of 32 bit floats"[D]"
... one depth component without specified type, which defaults to "undef" and implies that the default depth format should be used.
|
friend |
define stream out operator
stream out operator writes the component format in the syntax of description strings as defined in the docu of set_component_format().