/** ** File ......... BString.h ** Published .... 2005-06-14 ** Author ....... grymse@alhem.net **/ /* Copyright (C) 2005 Anders Hedstrom This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef _BSTRING_H #define _BSTRING_H #include "BTObject.h" #include "BTList.h" #include "BTInteger.h" #include "BTString.h" #define MAXL 100 //! metainfo file reader class BString { public: BString(); ~BString(); void read_file(FILE *fil); void read_buf(const char *,size_t); void Show(); BTObject *GetBTObject(const std::string &); BTInteger *GetInteger(const std::string &); BTString *GetString(const std::string &); std::string GetBString(const std::string& path); std::string printable(const std::string& s) { std::string str; for (size_t i = 0; i < s.size(); i++) { if (isprint(s[i])) str += s[i]; else str += "."; } return str; } size_t GetIndex() { return m_bindex; } unsigned char *GetHash(const std::string& node); const std::string& GetHashAsString(const std::string& node); private: bool reg_char(char); void AddDictionary(); void AddList(); void AddInteger(const std::string &); void AddString(const std::string &); void End(); // std::string m_bstring; size_t m_bindex; BTList m_root; BTObject *m_current; int m_state; int m_strlen; std::string m_str; std::string m_name; bool m_bDictionary; bool m_bList; bool m_bKey; // unsigned char m_hash[20]; std::string m_hash_str; }; #endif // _BSTRING_H