Main Page   Modules   Class Hierarchy   Compound List   File List   Compound Members   File Members   Related Pages   Examples  

node/field.cpp

Go to the documentation of this file.
00001 #include "field.h"
00002 
00007 #include <iostream>
00008 #include <iomanip>
00009 using namespace std;
00010 
00011 GltField::GltField()
00012 {
00013 }
00014 
00015 GltField::GltField(const string &name)
00016 : _name(name)
00017 {
00018 }
00019 
00020 GltField::GltField(const GltField &field)
00021 : _name(field._name) 
00022 {
00023 }
00024 
00025 GltField::~GltField()
00026 {
00027 }
00028 
00029 GltField &
00030 GltField::operator=(const GltField &field)
00031 {
00032     if (this!=&field)
00033     {
00034         _name        = field._name;
00035     //  _description = field._description;
00036     }
00037 
00038     return *this;
00039 }
00040 
00041 std::string GltField::get() const                   { return string(); }
00042 bool        GltField::set(const std::string &value) { return false;    }
00043 bool        GltField::reset()                       { return false;    }
00044 bool        GltField::isDefault() const             { return false;    }
00045 
00046 bool 
00047 GltField::write(ostream &os,const string &prefix) const
00048 {
00049     string fullName(prefix);
00050     if (prefix.size())
00051         fullName += ".";
00052     fullName += name() + ": ";
00053 
00054     os << setw(60) << setiosflags(ios::left) << fullName << get() << endl;
00055 
00056     return true;
00057 }
00058 
00059       string &GltField::name()       { return _name; }
00060 const string &GltField::name() const { return _name; }
00061 
00062 //
00063 // Windows specific
00064 //
00065 
00066 #ifdef GLT_WIN32
00067 
00068 #include <windows.h>
00069 
00070 bool 
00071 GltField::writeRegistry(void *key) const
00072 {
00073     if (!_name.size())
00074         return false;
00075 
00076     const string val = get();
00077     LONG res = RegSetValueEx((HKEY)key,_name.c_str(),0,REG_SZ,(CONST BYTE *) val.c_str(),val.size()+1);
00078     return res==ERROR_SUCCESS;
00079 }
00080 
00081 bool 
00082 GltField::readRegistry(void *key)
00083 {
00084     if (!_name.size())
00085         return false;
00086 
00087     const DWORD bufferMaxSize = 256;
00088     char buffer[bufferMaxSize];
00089     DWORD size = bufferMaxSize;
00090     DWORD type;
00091 
00092     LONG res = RegQueryValueEx((HKEY)key,_name.c_str(),0,&type,(BYTE *) buffer,&size);
00093     if (res==ERROR_SUCCESS && type==REG_SZ)
00094     {
00095         set(buffer);
00096         return true;
00097     }
00098 
00099     return false;
00100 }
00101 
00102 #endif

Generated on Tue Nov 5 11:11:05 2002 for GLT by doxygen1.2.18