Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

NDK_XX::NDKApplication Class Reference

#include <ndk++.h>

Inheritance diagram for NDK_XX::NDKApplication:

TestApplication List of all members.

Public Methods

virtual ~NDKApplication ()
NDKStatusBargetStatusBar ()
void set_param_file_name (const string &file_name)
 Tell us what is the name of the parameters file.

string get_param_file_name () const
 Retrive the parameters file name.

string get_param (const string &section_name,const string &key_name,const string &val)
 Find a string parameter (a la MS's .ini files).

long get_param (const string &section_name,const string &key_name,long val)
 Find a numeric parameter (a la MS's .ini files).

string save_param (const string &section_name,const string &key_name,const string &val)
 Save a string parameter (a la MS's .ini files).

long save_param (const string &section_name,const string &key_name,long val)
 Save a numeric parameter (a la MS's .ini files).


Static Public Methods

NDKApplication * get_application ()

Protected Methods

 NDKApplication (bool wantColors=FALSE)
virtual void activateMenuBar (ListOfItems &items)=0
virtual void activateStatusBar ()
bool section_exists (ifstream &param_file, const string &section_name)
 Helper to check if a section given in ge/save_param functs. exists.

long find_key (ifstream &param_file, const string &section_name,const string &key_name, string &value)
 Helper to check if a key given in ge/save_param functs. exists.


Protected Attributes

NDKStatusBarpStatusBar
string param_file_name

Constructor & Destructor Documentation

NDK_XX::NDKApplication::NDKApplication bool    wantColors = FALSE [inline, protected]
 

Definition at line 1321 of file ndk++.h.

References NDK_XX::ClosingMarkItem::ClosingMarkItem(), NDK_XX::NDKMenuItem::NDKMenuItem(), and NDK_XX::ClosingMarkItem::~ClosingMarkItem().

Referenced by TestApplication::TestApplication().

01321 {
01322 protected:
01323 public:
01324   ClosingMarkItem() : NDKMenuItem() { }

virtual NDK_XX::NDKApplication::~NDKApplication   [inline, virtual]
 

Definition at line 1337 of file ndk++.h.

01339                          {


Member Function Documentation

virtual void NDK_XX::NDKApplication::activateMenuBar ListOfItems   items [protected, pure virtual]
 

Implemented in TestApplication.

void NDK_XX::NDKApplication::activateStatusBar   [protected, virtual]
 

Definition at line 1797 of file ndk++.cc.

References pStatusBar.

Referenced by TestApplication::run().

01798 {
01799     pStatusBar = new NDKStatusBar(1,COLS,LINES-1,0);
01800     
01801 }

long NDK_XX::NDKApplication::find_key ifstream &    param_file,
const string &    section_name,
const string &    key_name,
string &    value
[protected]
 

Helper to check if a key given in ge/save_param functs. exists.

Definition at line 1825 of file ndk++.cc.

References section_exists().

Referenced by get_param().

01827 {
01828     long line_beg =0;
01829     if(section_exists(param_file,section_name)){
01830         string line;
01831         string found_key;
01832         char line_read[255]={0};
01833         for(    param_file.getline(line_read,sizeof(line_read));
01834                 param_file.good();
01835                 param_file.getline(line_read,sizeof(line_read))){
01836             line = line_read;
01837             line_beg = param_file.tellg();
01838             line_beg -= line.size();
01839             if(line.empty() || line[0]=='#')///Skip empty and comment lines
01840                 continue;
01841             if(line_read[0] == '[')///Reached the next section
01842                 break;
01843             int from= line.find_first_not_of(" \t");
01844             if(from == string::npos)//Non-empty, but all spaces...
01845                 continue;
01846             int to= line.rfind("#");///allow inline comments
01847             if(to!=string::npos){
01848                 line = line.substr(from,to-from);
01849             }
01850             to= line.find_last_not_of(" \t");
01851             line = line.substr(from,to-from+1);
01852             int eq_sign = line.find('=');
01853             found_key= line.substr(0,eq_sign);
01854             if(found_key == key_name){
01855                 if(to!=eq_sign && eq_sign!=string::npos){//no value...
01856                     value= line.substr(eq_sign+1);
01857                 }
01858                 break;
01859             }
01860         }
01861     }
01862     return line_beg;
01863 }

NDKApplication* NDK_XX::NDKApplication::get_application   [inline, static]
 

Definition at line 1331 of file ndk++.h.

References NDK_XX::NDKMenuItem::NDKMenuItem(), and NDK_XX::NonImplementedItem::NonImplementedItem().

01334                          : public NDKMenuItem {
01335 public:

long NDK_XX::NDKApplication::get_param const string &    section_name,
const string &    key_name,
long    val
 

Find a numeric parameter (a la MS's .ini files).

Definition at line 1884 of file ndk++.cc.

References get_param().

01886 {
01887     char txt[255]={0};
01888     ostrstream str_val(txt,sizeof(txt));
01889     str_val << val << ends;
01890     string result = get_param(section_name,key_name, str_val.str());
01891     return atol(result.c_str());
01892 ;
01893 }

string NDK_XX::NDKApplication::get_param const string &    section_name,
const string &    key_name,
const string &    val
 

Find a string parameter (a la MS's .ini files).

Definition at line 1867 of file ndk++.cc.

References find_key(), and param_file_name.

Referenced by get_param().

01869 {
01870     long pos=0;
01871     string value=val;
01872     if(!param_file_name.empty()){
01873         ifstream param_file(param_file_name.c_str());
01874         pos = find_key(param_file,section_name,key_name,value);
01875         if(pos && value.empty())
01876             value=val;
01877     }
01878         
01879     return value;   
01880 }

string NDK_XX::NDKApplication::get_param_file_name   const [inline]
 

Retrive the parameters file name.

Definition at line 1347 of file ndk++.h.

References NDK_XX::ExitCmd::action(), NDK_XX::ExitCmd::ExitCmd(), NDK_XX::NDKMenuItem::NDKMenuItem(), and NDK_XX::ExitCmd::~ExitCmd().

01348 : public NDKMenuItem

NDKStatusBar* NDK_XX::NDKApplication::getStatusBar   [inline]
 

Definition at line 1341 of file ndk++.h.

01348 : public NDKMenuItem

long NDK_XX::NDKApplication::save_param const string &    section_name,
const string &    key_name,
long    val
[inline]
 

Save a numeric parameter (a la MS's .ini files).

Definition at line 1365 of file ndk++.h.

01365       :
01366   BackCmd(const char *text="Back") : NDKMenuItem(text) { }
01367   ~BackCmd(){}
  bool action() { return TRUE; }

string NDK_XX::NDKApplication::save_param const string &    section_name,
const string &    key_name,
const string &    val
[inline]
 

Save a string parameter (a la MS's .ini files).

Definition at line 1360 of file ndk++.h.

01363               : public NDKMenuItem

bool NDK_XX::NDKApplication::section_exists ifstream &    param_file,
const string &    section_name
[protected]
 

Helper to check if a section given in ge/save_param functs. exists.

Definition at line 1805 of file ndk++.cc.

Referenced by find_key().

01806 {
01807     string tag("[" + section_name + "]");
01808     string line;
01809     char line_read[255]={0};
01810     for(    param_file.getline(line_read,sizeof(line_read));
01811             param_file.good();
01812             param_file.getline(line_read,sizeof(line_read))){
01813         if(line_read[0] == '['){
01814             line = line_read;
01815             if(line.find(tag)!= string::npos){
01816                 return true;
01817             }
01818         }
01819     }
01820     return false;
01821 }

void NDK_XX::NDKApplication::set_param_file_name const string &    file_name [inline]
 

Tell us what is the name of the parameters file.

Definition at line 1344 of file ndk++.h.

Referenced by TestApplication::run().

01348 : public NDKMenuItem


Member Data Documentation

string NDK_XX::NDKApplication::param_file_name [protected]
 

Definition at line 1372 of file ndk++.h.

Referenced by get_param().

NDKStatusBar* NDK_XX::NDKApplication::pStatusBar [protected]
 

Definition at line 1371 of file ndk++.h.

Referenced by activateStatusBar().


The documentation for this class was generated from the following files:
Generated on Tue Aug 27 10:49:45 2002 by doxygen1.2.17