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

NDK_XX::Application Class Reference

#include <ndk++.h>

Inheritance diagram for NDK_XX::Application:

TestApplication List of all members.

Public Methods

virtual ~Application ()
StatusBargetStatusBar ()
string get_title () const
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

Application * get_application ()

Protected Methods

 Application (bool wantColors=FALSE)
virtual void activateMenuBar ()=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

string app_title
StatusBarpStatusBar
string param_file_name

Constructor & Destructor Documentation

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

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

References NDK_XX::Exception< T >::Exception(), and NDK_XX::Exception< T >::pElem.

Referenced by TestApplication::TestApplication().

02097                                   : public NCursesException
02098 {
02099 public:

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

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

References NDK_XX::Exception< T >::pElem.

02114                       : 
02115     NCursesException ("NDK++ library exception", err),


Member Function Documentation

virtual void NDK_XX::Application::activateMenuBar   [protected, pure virtual]
 

Implemented in TestApplication.

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

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

References pStatusBar.

Referenced by TestApplication::run().

02607 {
02608     pStatusBar = new StatusBar(1,COLS,LINES-1,0);
02609     
02610 }

long NDK_XX::Application::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 2634 of file ndk++.cc.

References section_exists().

Referenced by get_param().

02636 {
02637     long line_beg =0;
02638     if(section_exists(param_file,section_name)){
02639         string line;
02640         string found_key;
02641         char line_read[255]={0};
02642         for(    param_file.getline(line_read,sizeof(line_read));
02643                 param_file.good();
02644                 param_file.getline(line_read,sizeof(line_read))){
02645             line = line_read;
02646             line_beg = param_file.tellg();
02647             line_beg -= line.size();
02648             if(line.empty() || line[0]=='#')///Skip empty and comment lines
02649                 continue;
02650             if(line_read[0] == '[')///Reached the next section
02651                 break;
02652             int from= line.find_first_not_of(" \t");
02653             if(from == string::npos)//Non-empty, but all spaces...
02654                 continue;
02655             int to= line.rfind("#");///allow inline comments
02656             if(to!=string::npos){
02657                 line = line.substr(from,to-from);
02658             }
02659             to= line.find_last_not_of(" \t");
02660             line = line.substr(from,to-from+1);
02661             int eq_sign = line.find('=');
02662             found_key= line.substr(0,eq_sign);
02663             if(found_key == key_name){
02664                 if(to!=eq_sign && eq_sign!=string::npos){//no value...
02665                     value= line.substr(eq_sign+1);
02666                 }
02667                 break;
02668             }
02669         }
02670     }
02671     return line_beg;
02672 }

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

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

References NDK_XX::Exception< T >::pElem.

02109                          : 
02110     NCursesException (msg.c_str(), err),
02111     pElem (elem)

long NDK_XX::Application::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 2693 of file ndk++.cc.

References get_param().

02695 {
02696     char txt[255]={0};
02697     ostrstream str_val(txt,sizeof(txt));
02698     str_val << val << ends;
02699     string result = get_param(section_name,key_name, str_val.str());
02700     return atol(result.c_str());
02701 ;
02702 }

string NDK_XX::Application::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 2676 of file ndk++.cc.

References find_key(), and param_file_name.

Referenced by get_param().

02678 {
02679     long pos=0;
02680     string value=val;
02681     if(!param_file_name.empty()){
02682         ifstream param_file(param_file_name.c_str());
02683         pos = find_key(param_file,section_name,key_name,value);
02684         if(pos && value.empty())
02685             value=val;
02686     }
02687         
02688     return value;   
02689 }

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

Retrive the parameters file name.

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

02123 {};

string NDK_XX::Application::get_title   const [inline]
 

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

02120 : 

StatusBar* NDK_XX::Application::getStatusBar   [inline]
 

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

02117 {};

long NDK_XX::Application::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 2141 of file ndk++.h.

string NDK_XX::Application::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 2136 of file ndk++.h.

bool NDK_XX::Application::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 2614 of file ndk++.cc.

Referenced by find_key().

02615 {
02616     string tag("[" + section_name + "]");
02617     string line;
02618     char line_read[255]={0};
02619     for(    param_file.getline(line_read,sizeof(line_read));
02620             param_file.good();
02621             param_file.getline(line_read,sizeof(line_read))){
02622         if(line_read[0] == '['){
02623             line = line_read;
02624             if(line.find(tag)!= string::npos){
02625                 return true;
02626             }
02627         }
02628     }
02629     return false;
02630 }

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

Tell us what is the name of the parameters file.

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

References NDK_XX::Exception< T >::pElem.

Referenced by TestApplication::run().

02120 : 


Member Data Documentation

string NDK_XX::Application::app_title [protected]
 

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

Referenced by TestApplication::TestApplication(), and TestApplication::title().

string NDK_XX::Application::param_file_name [protected]
 

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

Referenced by get_param(), and NDK_XX::PropertyDialog::on_page_selected().

StatusBar* NDK_XX::Application::pStatusBar [protected]
 

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

Referenced by activateStatusBar(), and NDK_XX::PropertyDialog::on_page_selected().


The documentation for this class was generated from the following files:
Generated on Thu Oct 10 16:02:11 2002 by doxygen1.2.17