Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

FileStorage is basically a key-value store.

fs << key << value;  // pseudo

you break it in the very first line:

fs << "style name";  // now, that's the "key", and where's the "value" ?

do you need that line at all ? or did you mean this ? :

fs << "style" << "name";

    FileStorage fs("my.yml",FileStorage::WRITE);
    if(fs.isOpened())
    {
        fs << "style" << "name";
        fs << "images" << "[";
        for(int i=0; i<3; i++)
        {
            fs << "{:";
            fs << "ImageID" << i;
            fs << "Height" << i;
            fs << "Width" << i;
            fs << "}";
        }
        fs << "]";
    }

    fs.release();

%YAML:1.0
style: name
images:
   - { ImageID:0, Height:0, Width:0 }
   - { ImageID:1, Height:1, Width:1 }
   - { ImageID:2, Height:2, Width:2 }