UniverseUniversity


Home Projects Jobs Clientele Contact

uu


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Yet another idea



Where is the guarantee that every object list is direct result of a query?
Plus, will you have a separate wrapper for every query?

IOW: what class is "topics" object in your example?

Alexey Parshin wrote:
I'm seeing a bit differently. The implementation should use not the
members of the class but fields in the underlying query. And the
parser should just once per loop, converting a template into a vector
of pairs of text an following field index, so the template:

<A href='HomeServlet?id={uv_id}'> {uv_name} </A>

is parsed (once, before the loop) into vector of pairs:

{ "<A href='HomeServlet?id=", 0 },
{ "'> ", 1 },
{ "</A>", -1}

The following loop would work really fast cause it doesn't parse anything.

Alexey

1 июля 2008 г. 16:12 пользователь Ilya A. Volynets-Evenbakh
<ilya@total-knowledge.com> написал:
In other words, what you are suggesting, is writing wrapper class for each
possible UMO collection, that would allow easy printing of enumerations
of such objects?

That may be a good idea, although parsing such templates will be
time consuming, I'm afraid. Another obvious problem is maintaining
such wrappers, whenever object structure changes (e.g. a new field
is added to UMO and needs to be exposed to list generators).

  Ilya.

Alexey Parshin wrote:
Илья,

Я тут подумал над тем, как бы избавиться от C++ циклов в .csp, в пользу
чего-нибудь более прозрачного, и вот что придумал. Почему бы нам, вместо
циклов, не предоставить генерацию по шаблону.

Вместо:

for (vector<CTopic>::iterator itor = topics.begin(); itor != topic.end();
itor++)
   out << "<A href='TopicServlet?topic_id=" << (*itor)->id << ">"  <<
itor->title << "'</A>";

сделаем более простое и прозрачное:

topics.forEach("<A href='TopicServlet?topic_id={id}> {title} </A>");

--
Alexey Parshin,
http://www.sptk.net






Authoright © Total Knowledge: 2001-2008