OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ossimLookUpTable Class Reference

#include <ossimLookUpTable.h>

Inheritance diagram for ossimLookUpTable:
ossimGeoTiffCoordTransformsLut ossimGeoTiffDatumLut ossimImageTypeLut ossimInterleaveTypeLut ossimRpfComponentIdLut ossimScalarTypeLut ossimUnitTypeLut

Classes

class  ossimKeyValueMap
 

Public Types

enum  { NOT_FOUND = -1 }
 

Public Member Functions

 ossimLookUpTable (const std::initializer_list< ossimString > &stringInitializer)
 By default if you just give an initializer list with strings then it will assume keys 0..n-1 for each string. More...
 
virtual ~ossimLookUpTable ()
 
virtual ossimString getEntryString (ossim_int32 entry_number) const
 
virtual ossimString getTableIndexString (ossim_uint32 table_index) const
 
virtual ossimString operator[] (ossim_int32 entry_number) const
 
virtual ossimString getEntryString (const ossimKeywordlist &kwl, const char *prefix=0) const
 
virtual ossim_int32 getEntryNumber (const char *entry_string, bool case_insensitive=true) const
 
virtual ossim_int32 getEntryNumber (const ossimKeywordlist &kwl, const char *prefix=0, bool case_insensitive=true) const
 
virtual ossimKeyword getKeyword () const
 
virtual ossim_uint32 getTableSize () const
 
void dumpValues (std::ostream &out) const
 

Protected Member Functions

 ossimLookUpTable (ossim_int32 table_size)
 
 ossimLookUpTable ()
 

Protected Attributes

std::vector< ossimKeyValueMaptheTable
 

Detailed Description

Definition at line 32 of file ossimLookUpTable.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
NOT_FOUND 

Definition at line 36 of file ossimLookUpTable.h.

37  {
38  NOT_FOUND = -1
39  };

Constructor & Destructor Documentation

◆ ossimLookUpTable() [1/3]

ossimLookUpTable::ossimLookUpTable ( const std::initializer_list< ossimString > &  stringInitializer)

By default if you just give an initializer list with strings then it will assume keys 0..n-1 for each string.

Definition at line 19 of file ossimLookUpTable.cpp.

20 {
21  ossim_uint32 idx = 0;
22  for(auto value:stringInitializer)
23  {
24  theTable.push_back(ossimKeyValueMap(idx, value));
25  ++idx;
26  }
27 }
std::vector< ossimKeyValueMap > theTable
unsigned int ossim_uint32

◆ ~ossimLookUpTable()

ossimLookUpTable::~ossimLookUpTable ( )
virtual

Definition at line 36 of file ossimLookUpTable.cpp.

37 {
38 }

◆ ossimLookUpTable() [2/3]

ossimLookUpTable::ossimLookUpTable ( ossim_int32  table_size)
protected

Definition at line 31 of file ossimLookUpTable.cpp.

32  :
33  theTable(table_size)
34 {}
std::vector< ossimKeyValueMap > theTable

◆ ossimLookUpTable() [3/3]

ossimLookUpTable::ossimLookUpTable ( )
inlineprotected

Definition at line 126 of file ossimLookUpTable.h.

126 {}

Member Function Documentation

◆ dumpValues()

void ossimLookUpTable::dumpValues ( std::ostream &  out) const

Definition at line 142 of file ossimLookUpTable.cpp.

References getTableSize(), and theTable.

143 {
144  ossim_uint32 tableSize = getTableSize();
145  ossim_uint32 i = 0;
146 
147  for(i = 0; i < tableSize; ++i)
148  {
149  out << theTable[0].theValue << std::endl;
150  }
151 }
std::vector< ossimKeyValueMap > theTable
unsigned int ossim_uint32
virtual ossim_uint32 getTableSize() const

◆ getEntryNumber() [1/2]

ossim_int32 ossimLookUpTable::getEntryNumber ( const char *  entry_string,
bool  case_insensitive = true 
) const
virtual

Returns the entry number associated with the entry string passed in. Returns NOT_FOUND(-1) if entry string is not in the list. If case_insensitive == true(default), the test is case insensitive; else, the test will be case sensitive.

Reimplemented in ossimUnitTypeLut.

Definition at line 87 of file ossimLookUpTable.cpp.

References ossimString::downcase(), ossimString::empty(), NOT_FOUND, theTable, and ossimString::trim().

Referenced by ossimUnitTypeLut::getEntryNumber(), getEntryNumber(), ossimImageFileWriter::getOutputImageType(), ossimScalarTypeLut::getScalarTypeFromString(), ossimGeneralRasterInfo::initializeFromHdr(), ossimSrtmSupportData::loadOmd(), ossimCastTileSourceFilter::loadState(), ossimNBandLutDataObject::loadState(), ossimCastTileSourceFilter::setOutputScalarType(), ossimBandLutFilter::setOutputScalarType(), and ossimCastTileSourceFilter::setProperty().

89 {
90  // Filter out trivial solution of NULL string:
91  ossimString s1 = entry_string;
92  if (!s1.empty())
93  {
94  s1 = s1.trim();
95  for (ossim_uint32 i=0; i<theTable.size(); i++)
96  {
97  ossimString s2 = theTable[i].theValue;
98 
99  if (case_insensitive == true)
100  {
101  s1.downcase();
102  s2.downcase();
103  }
104 
105  if (s1 == s2)
106  {
107  return theTable[i].theKey;
108  }
109  }
110  }
111 
112  return ossimLookUpTable::NOT_FOUND; // Entry number not found.
113 }
std::vector< ossimKeyValueMap > theTable
unsigned int ossim_uint32
ossimString trim(const ossimString &valueToTrim=ossimString(" \\)) const
this will strip lead and trailing character passed in.
static ossimString downcase(const ossimString &aString)
Definition: ossimString.cpp:48
bool empty() const
Definition: ossimString.h:411

◆ getEntryNumber() [2/2]

ossim_int32 ossimLookUpTable::getEntryNumber ( const ossimKeywordlist kwl,
const char *  prefix = 0,
bool  case_insensitive = true 
) const
virtual

Returns the entry number associated with the lookup table keyword entry in the Keywordlist passed in. Returns NOT_FOUND(-1) if no matching entry. If case_insensitive == true(default), the test is case insensitive; else, the test will be case sensitive.

Reimplemented in ossimUnitTypeLut.

Definition at line 118 of file ossimLookUpTable.cpp.

References ossimKeywordlist::find(), getEntryNumber(), getKeyword(), and NOT_FOUND.

121 {
122  const char* lookup = kwl.find(prefix, getKeyword());
123 
124  if (lookup)
125  {
126  return getEntryNumber(lookup, case_insensitive);
127  }
128 
129  return ossimLookUpTable::NOT_FOUND; // Entry number not found.
130 }
const char * find(const char *key) const
virtual ossimKeyword getKeyword() const
virtual ossim_int32 getEntryNumber(const char *entry_string, bool case_insensitive=true) const

◆ getEntryString() [1/2]

ossimString ossimLookUpTable::getEntryString ( ossim_int32  entry_number) const
virtual

◆ getEntryString() [2/2]

ossimString ossimLookUpTable::getEntryString ( const ossimKeywordlist kwl,
const char *  prefix = 0 
) const
virtual

Returns the entry string associated with lookup table keyword entry in the Keywordlist passed in. Returns empty string if keyword entry is not in the Keywordlist.

Definition at line 77 of file ossimLookUpTable.cpp.

References ossimKeywordlist::find(), and getKeyword().

79 {
80  ossimString s = kwl.find(prefix, getKeyword());
81  return s;
82 }
const char * find(const char *key) const
virtual ossimKeyword getKeyword() const

◆ getKeyword()

ossimKeyword ossimLookUpTable::getKeyword ( ) const
virtual

Returns keyword for lookups from a Keywordlist.

Reimplemented in ossimGeoTiffDatumLut, ossimGeoTiffCoordTransformsLut, ossimUnitTypeLut, ossimRpfComponentIdLut, ossimScalarTypeLut, ossimImageTypeLut, and ossimInterleaveTypeLut.

Definition at line 137 of file ossimLookUpTable.cpp.

Referenced by getEntryNumber(), and getEntryString().

138 {
139  return ossimKeyword();
140 }

◆ getTableIndexString()

ossimString ossimLookUpTable::getTableIndexString ( ossim_uint32  table_index) const
virtual
Parameters
table_indexIndex into the table Note: This is not the key mapped to the but the index into the table.
Returns
Returns the entry string associated with the table index passed in. Returns empty string if index is out of range.

Definition at line 59 of file ossimLookUpTable.cpp.

References theTable.

60 {
61  if (table_index < theTable.size())
62  {
63  return theTable[table_index].theValue;
64  }
65 
66  return ossimString(); // Index out of range.
67 }
std::vector< ossimKeyValueMap > theTable

◆ getTableSize()

ossim_uint32 ossimLookUpTable::getTableSize ( ) const
virtual

Definition at line 132 of file ossimLookUpTable.cpp.

References theTable.

Referenced by dumpValues(), and ossimEquationCombiner::getProperty().

133 {
134  return (ossim_uint32)theTable.size();
135 }
std::vector< ossimKeyValueMap > theTable
unsigned int ossim_uint32

◆ operator[]()

ossimString ossimLookUpTable::operator[] ( ossim_int32  entry_number) const
virtual

Returns the entry string associated with the entry number passed in. Returns empty string if entry number is not in the list.

Definition at line 69 of file ossimLookUpTable.cpp.

References getEntryString().

70 {
71  return getEntryString(entry_number);
72 }
virtual ossimString getEntryString(ossim_int32 entry_number) const

Member Data Documentation

◆ theTable

std::vector<ossimKeyValueMap> ossimLookUpTable::theTable
protected

The documentation for this class was generated from the following files: