string_table.h

Go to the documentation of this file.
00001 #ifndef STRING_TABLE_CLASS
00002 #define STRING_TABLE_CLASS
00003 
00004 /*****************************************************************************\
00005 *                                                                             *
00006 *  Name   : string_table                                                      *
00007 *  Author : Chris Koeritz                                                     *
00008 *                                                                             *
00009 *******************************************************************************
00010 * Copyright (c) 2000-$now By Author.  This program is free software; you can  *
00011 * redistribute it and/or modify it under the terms of the GNU General Public  *
00012 * License as published by the Free Software Foundation; either version 2 of   *
00013 * the License or (at your option) any later version.  This is online at:      *
00014 *     http://www.fsf.org/copyleft/gpl.html                                    *
00015 * Please send any updates to: fred@gruntose.com                               *
00016 \*****************************************************************************/
00017 
00018 #include "symbol_table.cpp"
00019 
00020 #include <basis/istring.h>
00021 #include <basis/packable.h>
00022 
00024 
00026 class DATA_STRUCTURE_CLASS_STYLE string_table
00027 : public symbol_table<istring>, public packable
00028 {
00029 public:
00030   string_table(int max_bits = 7) : symbol_table<istring>(max_bits),
00031       _add_spaces(false) {}
00035   string_table(const string_table &to_copy);
00036   virtual ~string_table();
00037 
00038   string_table &operator = (const string_table &to_copy);
00039 
00040   bool operator ==(const string_table &to_compare) const;
00041   bool operator !=(const string_table &to_compare) const
00042           { return !(*this == to_compare); }
00043 
00044   #define STRTAB_COMMENT_PREFIX "#comment#"
00046 
00049   static bool is_comment(const istring &to_check);
00050 
00051   istring text_form() const;
00053 
00056   // dictates whether the output will have spaces between the assignment
00057   // character and the key name and value.  default is to not add them.
00058   bool add_spaces() const { return _add_spaces; }
00059   void add_spaces(bool add_them) { _add_spaces = add_them; }
00060 
00061   virtual int packed_size() const;
00062   virtual void pack(byte_array &packed_form) const;
00063   virtual bool unpack(byte_array &packed_form);
00064 
00065 private:
00066   bool _add_spaces;  // records whether we add spaces around the assignment.
00067 };
00068 
00069 #endif
00070 

Generated on Fri Nov 21 04:29:42 2008 for HOOPLE Libraries by  doxygen 1.5.1