From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, HEADER_SPAM autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,745ecf6266b2fdbf X-Google-Attributes: gid103376,public X-Google-Thread: 109fba,745ecf6266b2fdbf X-Google-Attributes: gid109fba,public X-Google-Thread: 1014db,745ecf6266b2fdbf X-Google-Attributes: gid1014db,public X-Google-Thread: 100850,745ecf6266b2fdbf X-Google-Attributes: gid100850,public X-Google-ArrivalTime: 2003-02-15 12:14:06 PST Path: archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!pd2nf1so.cg.shawcable.net!residential.shaw.ca!chi1.webusenet.com!news.webusenet.com!newsfeed-east.nntpserver.com!nntpserver.com!news-out.visi.com!hermes.visi.com!gemini.plethora.net.POSTED!not-for-mail X-Old-trace: posting.google.com 1045208412 24235 127.0.0.1 (14 Feb 2003 07:40:12 GMT) Subject: Re: [ANN] an EBNF parser and coding pattern tool (LGPL) Content-Transfer-encoding: 8bit References: From: codeworker@free.fr (Cedric LEMAIRE) Organization: http://groups.google.com/ Return-Path: Content-Type: text/plain; charset=ISO-8859-1 X-Old-complaints-to: groups-abuse@google.com Newsgroups: comp.lang.c.moderated,comp.lang.ada,comp.lang.c,comp.lang.c++ Message-ID: Originator: clcm@plethora.net (Comp Lang C'Moderated) Date: 15 Feb 2003 20:14:04 GMT NNTP-Posting-Host: b45dc8c4.news.plethora.net X-Trace: 1045340044 gemini.plethora.net 79558 clcm@205.166.146.1 X-Complaints-To: abuse@plethora.net Xref: archiver1.google.com comp.lang.c.moderated:7441 comp.lang.ada:34133 comp.lang.c:173468 comp.lang.c++:203429 Date: 2003-02-15T20:14:04+00:00 List-Id: Stephen Leake wrote in message news:... > codeworker@free.fr (Cedric LEMAIRE) writes: > > > How to write with C++ templates an "Object Unmarshaller", for > > instance? I mean, something that reads the serialized content of an > > object and that builds the corresponding object in memory. Be > > careful! No intervention must be done on these objects in C++ to > > facilitate their integration into the "unmarshaller". > > C++ templates can't do this. Neither do Ada generics. But I could > easily write a code generator to do this with ASIS. > > Is there any language whose generics do this? Not a system programming language, but a scripting language: did you try 'CodeWorker' at "http://codeworker.free.fr"? I implemented these examples very easily in it. > > > How to write an "Object Walker", something that enables to navigate > > amongst the object attributes of the instances, for applying a task on > > them (starting from a given object: to initialize all of them or to > > serialize all of them or describing them in HTML to query the > > application from a browser ...)? > > You've lost me here. I want to navigate amongst the object attributes of (an instance of) a class, to apply a process on them. class A { ... public: virtual void accept(Visitor&); }; class B { ... A* a; public: virtual void accept(Visitor&); }; class C { ... A* a; std::vector list; public: virtual void accept(Visitor&); }; And now: void f(C& c) { HTMLVisitor processToApplyRecursivelyOnObjects; ObjectWalker walker(processToApplyRecursivelyOnObjects); walker.navigate(c); } where the instance c and all its associations/aggregations (attributes 'a' and 'list') will be written in HTML, propagating the process on object attributes (c.a and c.list[i] and c.list[i].a ...) recursively. 'HTMLVisitor' is a visitor that knows how to serialize in HTML all instances of A, B and C. It cannot be written with C++ templates. By hand? I'm used to work on Business applications of a few hundred classes and a few thousand attributes (associations and other). 'ObjectWalker' cannot be written with C++ templates. It has to know the composition of each class. However, these classes can be written with 'CodeWorker' very easily. > If I need to navigate a tree, I first have to > build the tree, presumably using a tree class. Then the tree class > must provide a "walker" (aka "iterator"). Where do "generics" or > "templates" come into it? > Your tree is an kind of 'abstract tree of object dependencies'. It is an instance and its associations/aggregations. I don't want to build a structure for it: it is already present as the representation of the instance in memory. Templates and generics aren't helpful here. -- C�dric -- comp.lang.c.moderated - moderation address: clcm@plethora.net