PLearn 0.1
Public Member Functions | Public Attributes
PLearn::NumToStringMapping Class Reference

#include <AutoSDBVMatrix.h>

Collaboration diagram for PLearn::NumToStringMapping:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 NumToStringMapping ()
 NumToStringMapping (string filename_, const string &dft_val_="")
void read (istream &in) const
void load (string filename_="")
void load () const
const string & operator[] (real x) const

Public Attributes

string filename
string dft_val
hash_map< real, string > mapping
bool loaded

Detailed Description

Definition at line 99 of file AutoSDBVMatrix.h.


Constructor & Destructor Documentation

PLearn::NumToStringMapping::NumToStringMapping ( ) [inline]

Definition at line 108 of file AutoSDBVMatrix.h.

        :loaded(false)
    {}
PLearn::NumToStringMapping::NumToStringMapping ( string  filename_,
const string &  dft_val_ = "" 
) [inline]

Definition at line 112 of file AutoSDBVMatrix.h.

        :filename(filename_), dft_val(dft_val_), mapping(), loaded(false)
    {}

Member Function Documentation

void PLearn::NumToStringMapping::load ( string  filename_ = "") [inline]

Definition at line 129 of file AutoSDBVMatrix.h.

References PLearn::read().

    {
        if(filename_ != "")
            filename= filename_;
        ifstream f(filename.c_str());
        read(f);
    }

Here is the call graph for this function:

void PLearn::NumToStringMapping::load ( ) const [inline]

Definition at line 137 of file AutoSDBVMatrix.h.

References PLearn::read().

    {
        ifstream f(filename.c_str());
        read(f);
    }

Here is the call graph for this function:

const string& PLearn::NumToStringMapping::operator[] ( real  x) const [inline]

Definition at line 143 of file AutoSDBVMatrix.h.

References PLearn::load(), and x.

    {
        if(!loaded) load();
        if(mapping.end() == mapping.find(x))
            return dft_val;
        return mapping[x]; 
    }

Here is the call graph for this function:

void PLearn::NumToStringMapping::read ( istream &  in) const [inline]

Definition at line 116 of file AutoSDBVMatrix.h.

References PLearn::read().

    {
        while(in)
        {
            string s;
            PLearn::read(in, s);
            real val;       
            PLearn::read(in, val);
            if(in) mapping[val]= s;
        }
        loaded= true;
    }

Here is the call graph for this function:


Member Data Documentation

Definition at line 104 of file AutoSDBVMatrix.h.

Definition at line 103 of file AutoSDBVMatrix.h.

Definition at line 106 of file AutoSDBVMatrix.h.

hash_map<real, string> PLearn::NumToStringMapping::mapping [mutable]

Definition at line 105 of file AutoSDBVMatrix.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines