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

vecread.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 "../sexpress/sexpress.hpp"
00017 #include "../sexpress/svector.hpp"
00018 #include "sreader.hpp"
00019 
00020 static void do_process(int depth, SReference rest, SVectorRef &vec, bool rs)
00021 {
00022     SExpressionCons *dp = rest.DynamicCastGetPtr<SExpressionCons>();
00023     if(!dp) {
00024         vec = new SExpressionVector(rs ? 0 : depth);
00025     } else {
00026         do_process(depth+1, dp->Cdr(), vec, rs);
00027         vec[depth] = dp->Car();
00028     }
00029 }
00030 
00031 static SReference process_fixed_vectors(const SReference &list)
00032 {
00033     SVectorRef vr;
00034     do_process(0, list, vr, false);
00035     return vr;
00036 }
00037 
00038 static SReference process_resizeable_vectors(const SReference &list)
00039 {
00040     SVectorRef vr;
00041     do_process(0, list, vr, true);
00042     return vr;
00043 }
00044 
00045 void add_vectors_to_reader(class IntelibReader &reader)
00046 {
00047     reader.AddSequenceOpener("#(", process_fixed_vectors, ")");
00048     reader.AddSequenceOpener("#~(", process_resizeable_vectors, ")");
00049 }

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