name: NameMap

synopsis:

g++ [flags ...] NameMap ... -l /isip/tools/lib/$ISIP_BINARY/lib_io.a

#include <NameMap.h>

NameMap(const unichar* arg, unichar delim = DEF_DELIM);
const SysString& getName(long index) const;
const SysString& operator()(long index_a) const;
long getName(const SysString& name) const;
long operator()(const SysString& name) const;
quick start:

class Choices {

  // public constants
  //
  enum TYPES {FULL = 0, TRIANGULAR, SPARSE, SYMMETRIC, DIAGONAL};

  static NameMap TYPE_MAP;

};

// the instantiation is outside the header file, probably at the
// bottom of the default constructor's file
//
NameMap Choices::TYPE_MAP(L"FULL, TRIANGULAR, SPARSE, SYMMETRIC, DIAGONAL");

boolean OtherClass::doSomething() {

  Choices::TYPES type = Choices::FULL;

  SysString output(L"they selected choice ");

  // cast the enum to a long integer to get the index
  //
  output.concat(Choices::TYPE_MAP((long)type);
  Console::put(output);
}
description:

The NameMap class provides all classes using enumerated types with an ability to associate textual names for each value of the type. This class will generally be static class data where the names are set in the constructor.

Namemap is meant to be used for relatively small lists - typically 10 items or less. The size of the list is restricted to 65,536 - a 16-bit index is used to store the index. The list is searched linearly.

In order to conserve disk space for binary files, when the index of an item is written to disk, the index and a checksum for the map is written, rather than the entire map. This provides an added level of insurance that the map hasn't changed since the index was written to a file. For text files, the index is written as a name, which is a convenient way to deal with changes in the map (as long as the name is found in the map, processing will proceed as normal).

dependencies:

public constants:

error codes:

protected data:

required public methods:

class-specific public methods:

private methods:

examples:

notes: