PKFmanip.h

00001 #ifndef __PKF_MANIP_H__
00002 #define __PKF_MANIP_H__
00003 
00004 #include <stdlib.h>
00005 #include <string.h>
00006 #include <iostream>
00007 #include <assert.h>
00008 
00009 // using namespace std;
00010 using std::cout;
00011 using std::cerr;
00012 using std::istream;
00013 using std::endl;
00014 using std::ostream;
00015 
00016 static const char szPKFString[]="PKF 0.2";
00017 
00018 class PKFmanip {
00019 
00020   char* _NameString;
00021   char* _EticString;
00022   char* _CiteString;
00023   char* _HistoryString;
00024 
00025   void init();
00026   void clear();
00027 
00028   inline char *setString(const char *string);
00029   char *readString(istream &is,const char *szLengthTag,
00030                    const char *szTag);
00031   void writeString(ostream &os,const char *szLengthTag,
00032                    const char *szTag,const char *szString);
00033 
00034  public:
00035 
00036   PKFmanip();
00037   PKFmanip(const PKFmanip &h);
00038   PKFmanip &operator= (const PKFmanip &h);
00039   ~PKFmanip();
00040 
00041   void header(const char* name="No name",const char* etic="",
00042               const char *cite="", const char *history="");
00043 
00044   void setName(const char *name);
00045   void setEtic(const char *etic);
00046   void setCite(const char *cite);
00047   void setHistory(const char *history);
00048   const char *getName() const;
00049   const char *getEtic() const;
00050   const char *getCite() const;
00051   const char *getHistory() const;
00052 
00053   int readHeader(istream& in);
00054   int writeHeader(ostream& out);
00055 
00056   friend ostream & operator<<(ostream &out, PKFmanip &c);
00057 };
00058 
00059 inline ostream &operator<<(ostream &out, PKFmanip &pkf) {
00060   
00061   // Spit out PKF header
00062   pkf.writeHeader(out);
00063   return out;
00064 }
00065 
00066 inline char* PKFmanip::setString(const char *string) {
00067   char *tmp = new char[strlen(string)+1];
00068   strcpy(tmp,string);
00069   return tmp;
00070 }
00071 
00072 
00073 #endif // __PKF_MANIP_H__

Generated on Mon Feb 8 17:22:35 2010 for libbiarc by  doxygen 1.5.6