Home Projects Jobs Clientele Contact


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

Re: Yet another idea

Let me repeat the question: what is the data type of "topics" variable?

Alexey Parshin wrote:
If the list isn't result of the query - it's not related to the
database and should be static.
Most likely, I'd have wrappers for all the queries - to keep 'em
auto-prepared and re-used.

Topic is a UMO. UMOs are stored in umo_version table. There is no name
or title for a UMO in that table, so we need some query to get it.
Otherwise, it's trivial.

2008/7/1 Ilya A. Volynets-Evenbakh <ilya@total-knowledge.com>:
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.


1 июля 2008 г. 16:12 пользователь Ilya A. Volynets-Evenbakh
<ilya@total-knowledge.com> написал:

In other words, what you are suggesting, is writing wrapper class for
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).


Alexey Parshin wrote:


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


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

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

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

Alexey Parshin,

Authoright © Total Knowledge: 2001-2008