Menu

How to use the Keydata class?

Help
2000-07-05
2000-10-13
  • Raphael Alla

    Raphael Alla - 2000-07-05

    I have been trying to use the keydata class, without any success.
    I have two questions (and found a bug):

    1) what is the kind of path that can be given in the constructor, and what file is it going to read? The Load function seemd to do very weird things.

    What is the point of determining a file name in such a complicated way from a path. Why not have the name of the file passed as an argument directly?

    2) what format does the config file must respect to be read?

    BUG) The bug is that the current Load function checks for the presence of a "~" in the path name to determine if it will be a /etc subdirectory of a $HOME subdirectory. However, on some systems (such as AIX), something like ~/abc is converted automatically to /home/username/abc

     
    • David Sugar

      David Sugar - 2000-07-05

      Keydata is one of those really neat and odd things that I use heavily in things
      like Bayonne.  Essentially, the "path" is a "keypath" into a theoretical namespace of key pairs, hence one does not use "real" filepaths that may be OS dependent.  The "/" path refers to "/etc" prefixed  (on UNIX) directories and this is processed within the constructor.   It could refer to the /config prefix on QNX, or even, gasp, a "C:\WINDOWS".  Hence, a keypath of "/bayonne.d/vmhost/smtp" actually resolves to a "/etc/bayonne.d/vmhost.conf" and loads key value pairs from the [smtp] section of that .conf file.

      Similarly, something like "~bayonne/smtp" path refers to a "~/.bayonnerc" and loads key pairs from the [smtp] section.  This coercion occurs before the name is passed to the open call.

      I actually use derived keydata based classes as global initialized objects, and they hence automatically load and parse config file entries even before "main" has started.

       
      • Raphael Alla

        Raphael Alla - 2000-07-13

        Thanks for the explaination.

        I would recommend to actually add something like this to the keydata documentation, possibly along with an example of a rc file. It is not that obvious that the syntax is
        [section_name]
        key1=value1
        key2=value2
        ...

         
        • David Sugar

          David Sugar - 2000-07-14

          This probably should be documented somewhere...

           
          • Olleg Samoylov

            Olleg Samoylov - 2000-10-13

            I could undestend how it work only after looking in keydata.cpp
            The automatic generated document is not good due to unclear comments or even missing (as for getSymbol). Much better in OVERVIEW.txt but also don't clear enough.

             

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.