Logo
~Apps~
~Projects~
~Contact~


BString.h

Go to the documentation of this file.
00001 
00006 /*
00007 Copyright (C) 2005  Anders Hedstrom
00008 
00009 This program is free software; you can redistribute it and/or
00010 modify it under the terms of the GNU General Public License
00011 as published by the Free Software Foundation; either version 2
00012 of the License, or (at your option) any later version.
00013 
00014 This program is distributed in the hope that it will be useful,
00015 but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 GNU General Public License for more details.
00018 
00019 You should have received a copy of the GNU General Public License
00020 along with this program; if not, write to the Free Software
00021 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022 */
00023 #ifndef _BSTRING_H
00024 #define _BSTRING_H
00025 
00026 #include "BTObject.h"
00027 #include "BTList.h"
00028 #include "BTInteger.h"
00029 #include "BTString.h"
00030 
00031 #define MAXL 100
00032 
00033 
00035 
00036 class BString
00037 {
00038 public:
00039         BString();
00040         ~BString();
00041 
00042         void read_file(FILE *fil);
00043         void read_buf(const char *,size_t);
00044 
00045         void Show();
00046 
00047         BTObject *GetBTObject(const std::string &);
00048         BTInteger *GetInteger(const std::string &);
00049         BTString *GetString(const std::string &);
00050         std::string GetBString(const std::string& path);
00051 
00052         std::string printable(const std::string& s) {
00053                 std::string str;
00054                 for (size_t i = 0; i < s.size(); i++)
00055                 {
00056                         if (isprint(s[i]))
00057                                 str += s[i];
00058                         else
00059                                 str += ".";
00060                 }
00061                 return str;
00062         }
00063         size_t GetIndex() { return m_bindex; }
00064         unsigned char *GetHash(const std::string& node);
00065         const std::string& GetHashAsString(const std::string& node);
00066 
00067 private:
00068         bool reg_char(char);
00069         void AddDictionary();
00070         void AddList();
00071         void AddInteger(const std::string &);
00072         void AddString(const std::string &);
00073         void End();
00074         //
00075         std::string m_bstring;
00076         size_t m_bindex;
00077         BTList m_root;
00078         BTObject *m_current;
00079         int m_state;
00080         int m_strlen;
00081         std::string m_str;
00082         std::string m_name;
00083         bool m_bDictionary;
00084         bool m_bList;
00085         bool m_bKey;
00086         //
00087         unsigned char m_hash[20];
00088         std::string m_hash_str;
00089 };
00090 
00091 
00092 #endif // _BSTRING_H
00093 
Page, code, and content Copyright (C) 2006 by Anders Hedström
Generated on Mon Aug 29 20:21:47 2005 for C++ Sockets by  doxygen 1.4.4