form_loader - ryzom/ryzomcore GitHub Wiki


title: Reading sheets using the form loader description: published: true date: 2023-03-01T05:22:54.174Z tags: editor: markdown dateCreated: 2022-03-16T10:34:59.938Z

Loading

For simple loading of sheets, you need to do the following.

  1. You've have added the search path for the sheets you want to load.

  2. You also need to have the required DFN and TYP files in you serach path.

  3. Create a georges form loader.

    NLGEORGES::UFormLoader *formLoader = NLGEORGES::UFormLoader::createLoader();

    This loader can be used to load many sheets, so keep it. {.is-info}

     

  4. Load a form

    NLMISC::CSmartPtr<NLGEORGES::UForm> form = formLoader->loadForm("the_sheet_file.sheet_type");

    sheet_type is the extension of the sheet file. It must match with the dfn name for example foo.dfn will allow loading of *.foo sheets.

    In other words, when loadForm is passed bar.foo as an input file, it will try to find the foo.dfn format file. If it doesn't find it, the loading fail.

Read values

Now you have the form you can acces data using the form interface by gaining acces to the root element of the form using.

const NLGEORGES::UFormElm &formElm = form->getRootNode()

Then you can access data like this.

bool myBool;
formElm.getValueByName(myBool, "a_name.a_sub_part.a_data_as_boolean");

You have the equivalent setValueByName to set the value in an element. {.is-info}

Look at UFormElem for a complete list of accessors.

Source

⚠️ **GitHub.com Fallback** ⚠️