dlang-community / D-YAML

YAML parser and emitter for the D programming language
https://dlang-community.github.io/D-YAML/
Boost Software License 1.0
118 stars 38 forks source link

Question about D-YAML #9

Closed enjoysmath closed 11 years ago

enjoysmath commented 11 years ago

Where can I send you an email?

Question: Does D-YAML support writing just a single piece of data to the file instead of writing the whole file each time you want to save something. For instance, this would be great if you wanted to continually save an applications project file in the background. If the file's huge it would be to much overhead to write the whole thing each time and that limits you to having the user choose when to save their project.

SDLang-D doesn't support this afaik.

Thank you!

kiith-sa commented 11 years ago

At the moment, it doesn't, and it's unlikely to happen in the near future unless it's implemented by someone other than me (and would require quite a lot of work - D:YAML is not really designed with partial writing in mind). I keep maintaining D:YAML compatibility with current DMD, but I'm not adding new features at the moment due to time constraints.

At the same time, I'd suggest to just try saving the whole file. It might not necessarily be as slow as you think. Another alternative is to use many small files, though this still causes per-file overhead. Many games avoid this overhead by using virtual file systems where many logical files are packed into few physical ones (eliminating per-file overhead).

Now that I think of it, you can work with strings directly instead of files with D:YAML. So you could use some kind of a meta-yaml file, containing multiple parts, each representing a YAML "file". This is just an idea, it'd need a bit of work to do (in code using D:YAML, not D:YAML itself), but should be manageable.

Also, it might be easier, in D:YAML, to implement at least document writing without rewriting the whole file. (easier compared to partially rewriting at arbitrary change).

Also, mail is on http://dyaml.alwaysdata.net/ .

enjoysmath commented 11 years ago

Yeah, I just realized this is probably a bad idea. For instance the number 39393 in text is smaller than the number 109239012, so editing in place would cause the whole file to have to be shifted, unless you had some sort of link structure in your file to continue growing parts. But then the file becomes not very human-readable. I will rewrite the whole file for now and maybe do an autosave every 5 mins feature or something.

Thanks!

On Fri, May 24, 2013 at 7:33 PM, Ferdinand Majerech < notifications@github.com> wrote:

At the moment, it doesn't, and it's unlikely to happen in the near future unless it's implemented by someone other than me (and would require quite a lot of work - D:YAML is not really designed with partial writing in mind). I keep maintaining D:YAML compatibility with current DMD, but I'm not adding new features at the moment due to time constraints.

At the same time, I'd suggest to just try saving the whole file. It might not necessarily be as slow as you think. Another alternative is to use many small files, though this still causes per-file overhead. Many games avoid this overhead by using virtual file systems where many logical files are packed into few physical ones (eliminating per-file overhead).

Now that I think of it, you can work with strings directly instead of files with D:YAML. So you could use some kind of a meta-yaml file, containing multiple parts, each representing a YAML "file". This is just an idea, it'd need a bit of work to do (in code using D:YAML, not D:YAML itself), but should be manageable.

Also, it might be easier, in D:YAML, to implement at least document writing without rewriting the whole file. (easier compared to partially rewriting at arbitrary change).

Also, mail is on http://dyaml.alwaysdata.net/ .

— Reply to this email directly or view it on GitHubhttps://github.com/kiith-sa/D-YAML/issues/9#issuecomment-18438454 .