From: drhowarddrfine on
I don't want to use a db manager, like mysql, for such a small
database but I'm finding this trickier than I thought and hope someone
can provide some guidance.

I have a restaurant menu with prices and other info in a small file.
It's set up in a YAML-ish style, if you're familiar with that format.
I'm just looking for some ideas on the best way to retrieve data based
on a "keyword". What complicates things for me is that some of these
keywords might be inside a nested block, such as "prices:".

-navigation
link: link1
link: link2
-menu
chicken:
-roasted
-fried
steak:
-strip
prices:
small: 15.00
medium: 17.00
large: 19.00
-sirloin
prices:
small: 15.00
fish:
-location

In the above example, indentation matters. I am not bound by this
format so better ideas are welcome, but searching for menu->steak-
>strip->prices->large returning "19.00" seems logical to me.

What complicates things is when I want to do something like
"next_record()". It must tell me there are no more prices in "strip"
and not mistakenly search into the "prices" records of "sirloin".

Is my whole concern my answer, too? That I am trying to write a small
db manager and it's not a simple solution? Or is there simply a
better idea I'm missing?

Originally I did this in XML but felt parsing the tags wasn't any
easier and my format, above, is more readable. I can't just store a
struct in the file because I want it to be editable with any text
editor.

Thanks,
Doc
From: Phil on
drhowarddrfine wrote:
> I don't want to use a db manager, like mysql, for such a small
> database but I'm finding this trickier than I thought and hope someone
> can provide some guidance.
>
> I have a restaurant menu with prices and other info in a small file.
> It's set up in a YAML-ish style, if you're familiar with that format.
> I'm just looking for some ideas on the best way to retrieve data based
> on a "keyword". What complicates things for me is that some of these
> keywords might be inside a nested block, such as "prices:".
>
> -navigation
> link: link1
> link: link2
> -menu
> chicken:
> -roasted
> -fried
> steak:
> -strip
> prices:
> small: 15.00
> medium: 17.00
> large: 19.00
> -sirloin
> prices:
> small: 15.00
> fish:
> -location
>
> In the above example, indentation matters. I am not bound by this
> format so better ideas are welcome, but searching for menu->steak-
>> strip->prices->large returning "19.00" seems logical to me.
>
> What complicates things is when I want to do something like
> "next_record()". It must tell me there are no more prices in "strip"
> and not mistakenly search into the "prices" records of "sirloin".
>
> Is my whole concern my answer, too? That I am trying to write a small
> db manager and it's not a simple solution? Or is there simply a
> better idea I'm missing?
>
> Originally I did this in XML but felt parsing the tags wasn't any
> easier and my format, above, is more readable. I can't just store a
> struct in the file because I want it to be editable with any text
> editor.

This is the sort of thing that xpath queries can do reasonably well.

xpath is not something that I would often recommend, but this is
possibly one of them depending on the framework that you're implementing
this in.


Phil.

From: Scott Lurndal on
drhowarddrfine <robbelics(a)gmail.com> writes:
>I don't want to use a db manager, like mysql, for such a small
>database but I'm finding this trickier than I thought and hope someone
>can provide some guidance.

>Originally I did this in XML but felt parsing the tags wasn't any
>easier and my format, above, is more readable. I can't just store a
>struct in the file because I want it to be editable with any text
>editor.

XML is very natural for this. You can use very simple xpath
expressions in a XSL stylesheet to extract elements, including
nested ones, without having to parse the tags yourself.


scott
From: Måns Rullgård on
scott(a)slp53.sl.home (Scott Lurndal) writes:

> drhowarddrfine <robbelics(a)gmail.com> writes:
>>I don't want to use a db manager, like mysql, for such a small
>>database but I'm finding this trickier than I thought and hope someone
>>can provide some guidance.
>
>>Originally I did this in XML but felt parsing the tags wasn't any
>>easier and my format, above, is more readable. I can't just store a
>>struct in the file because I want it to be editable with any text
>>editor.
>
> XML is very natural for this. You can use very simple xpath

XML ... simple ... xpath, now there's a contradiction if ever there
was one.

Anyone advocating use of XML should be forced to write a
fully-featured parser using only standard ISO C.

--
M�ns Rullg�rd
mans(a)mansr.com
From: toby on
On Jun 24, 1:36 pm, drhowarddrfine <robbel...(a)gmail.com> wrote:
> I don't want to use a db manager, like mysql, for such a small
> database

I think you've just found the reason why people DO. ... Or do you have
unlimited time to spend on this?

> ...
> Thanks,
> Doc