libgta 1.2.1 Read and Write Generic Tagged Array (GTA) files

Examples written in C++: Using tags
/* This file is in the public domain. */
#include <iostream>
#include <gta/gta.hpp>
int main(void)
{
try {
gta::header header;
const char *name, *value;
/* Create an example GTA */
header.set_components(gta::uint16, gta::float32, gta::cfloat64);
header.set_dimensions(170, 190);
/* The global taglist contains tags that affect the whole array */
/* Set a tag */
header.global_taglist().set("PRODUCER", "FOO");
/* Get a tag */
value = header.global_taglist().get("X-BAR");
if (!value) {
/* This tag is undefined */
}
else if (value[0] == '\0') {
/* This tag is defined but empty */
}
else {
/* This tag is defined and not empty */
}
/* Unset a tag, whether it is defined or not */
header.global_taglist().unset("X-FOO");
/* Unset all tags (clear the taglist) */
header.global_taglist().unset_all();
/* Access all tags in the list */
for (uintmax_t t = 0; t < header.global_taglist().tags(); t++) {
name = header.global_taglist().name(t);
value = header.global_taglist().value(t);
}
/* The dimension taglists contain tags that affect the array dimensions */
header.dimension_taglist(0).set("INTERPRETATION", "X");
/* ... */
header.dimension_taglist(1).set("INTERPRETATION", "Y");
/* ... */
/* The component taglists contain tags that affect the array element components */
header.component_taglist(0).set("INTERPRETATION", "X-FOO");
/* ... */
header.component_taglist(1).set("UNIT", "m");
/* ... */
header.component_taglist(2).set("X-FOO", "BAR");
/* ... */
}
catch (std::exception &e) {
std::cerr << e.what() << std::endl;
return 1;
}
return 0;
}
gta::header
The GTA header.
Definition: gta.hpp:702
gta::header::component_taglist
const taglist & component_taglist(uintmax_t i) const
Get the component tag list.
Definition: gta.hpp:994
gta::header::global_taglist
const taglist & global_taglist() const
Get the global tag list.
Definition: gta.hpp:937
gta::header::set_components
void set_components(uintmax_t n, const type *types, const uintmax_t *sizes=NULL)
Set the components of an array element.
Definition: gta.hpp:1114
gta::header::set_dimensions
void set_dimensions(uintmax_t n, const uintmax_t *sizes)
Set the dimensions.
Definition: gta.hpp:1215
gta::header::dimension_taglist
const taglist & dimension_taglist(uintmax_t i) const
Get the dimension tag list.
Definition: gta.hpp:1033
gta::taglist::set
void set(const char *name, const char *value)
Set a tag.
Definition: gta.hpp:325
gta::taglist::unset_all
void unset_all()
Unset all tags.
Definition: gta.hpp:354
gta::taglist::get
const char * get(const char *name) const
Get a tag value by its name.
Definition: gta.hpp:311
gta::taglist::unset
void unset(const char *name)
Unset a tag.
Definition: gta.hpp:340
gta::taglist::value
const char * value(uintmax_t i) const
Get a tag value.
Definition: gta.hpp:301
gta::taglist::name
const char * name(uintmax_t i) const
Get a tag name.
Definition: gta.hpp:291
gta.hpp
The libgta C++ interface.
gta::float32
@ float32
IEEE 754 single precision floating point (on many platforms: float)
Definition: gta.hpp:132
gta::uint16
@ uint16
uint16_t
Definition: gta.hpp:125
gta::cfloat64
@ cfloat64
complex (re,im) based on two gta::float64
Definition: gta.hpp:136