Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

hshread.cpp

Go to the documentation of this file.
00001 // +-------------------------------------------------------------------------+
00002 // |               I__n__t__e__L__i__b           0.6.10 development          |
00003 // | Copyright (c) Andrey Vikt. Stolyarov <crocodil_AT_croco.net> 2000-2007. |
00004 // |                                                                         |
00005 // | This is free software. The library part is available under              |
00006 // |                               GNU LESSER GENERAL PUBLIC LICENSE v.2.1.  |
00007 // | GNU LGPL v2.1 is found in docs/gnu_gpl2.txt,  or at  http://www.gnu.org |
00008 // |     Please see also docs/readme.txt and visit http://www.intelib.org    |
00009 // |                                                                         |
00010 // | !!! THERE IS NO WARRANTY OF ANY KIND, NEITHER EXPRESSED NOR IMPLIED !!! |
00011 // +-------------------------------------------------------------------------+
00012 
00013 
00014 
00015 
00016 #include <string.h>
00017 #include "../sexpress/sexpress.hpp"
00018 #include "../sexpress/shashtbl.hpp"
00019 #include "sreader.hpp"
00020 
00021 
00022 static SReference process_hashtable_seq(const SReference &ls)
00023 {
00024     SReference list(ls.Cdr()); // first atom is HASH-TABLE and it is ignored
00025     // now EQ, EQL or EQUAL follows
00026     // it is unlikely that Reader is used with text represetnations off    
00027     SString pred = list.Car()->TextRepresentation().c_str();
00028     SHashTableRef res;
00029     if(strcasecmp(pred.c_str(), "EQ") == 0)
00030         res = new SExpressionHashTable(SExprsAreEq);
00031     else
00032     if(strcasecmp(pred.c_str(), "EQL") == 0)
00033         res = new SExpressionHashTable(SExprsAreEql);
00034     else
00035     if(strcasecmp(pred.c_str(), "EQUAL") == 0)
00036         res = new SExpressionHashTable(SExprsAreEqual);
00037     else // by default, let's assume the default
00038         res = new SExpressionHashTable();
00039     list = list.Cdr();
00040 
00041     // now the sequence follows
00042     while(!list.IsEmptyList()) {
00043         res->AddItem(list.Car().Car(), list.Car().Cdr());
00044         list = list.Cdr();
00045     }
00046 
00047     return res;
00048 }
00049 
00050 void add_hashtables_to_reader(class IntelibReader &reader)
00051 {
00052     reader.AddSequenceOpener("#s(", process_hashtable_seq, ")");
00053     reader.AddSequenceOpener("#S(", process_hashtable_seq, ")");
00054 }

Generated on Tue Dec 18 00:39:43 2007 for InteLib by  doxygen 1.4.1