Implement settings?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Xillez
    New Member
    • Jul 2013
    • 93

    #1

    Implement settings?

    Hey, I wander if it is possible to use file types like: .info, .settings, .xlm, .properties or .ylm in a standard win32 program (without using "#include <fstream>") for settings?
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    fstream is a C++ I/O library. It has nothing to do with win32. File names in win32 are internally mapped to a value used by Windows. Your file names can be anything you want

    Comment

    • Xillez
      New Member
      • Jul 2013
      • 93

      #3
      no, I know that fstream doesn't have any thing with win32 api but I dont want to use it because I loose effiency by using it... so I wanna know if it is a nother way of implementing a settings file and if so how?

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        Actually, fstream has a buried FILE* used in C. Plus it also uses other file functions from C. fstream is a template that wraps C file I/O and is designed for speed. It also makes file handling consistent rather then having each program use home-grown file handling code.

        You can, of course, write your own I/O code but it will not be any faster and it will be incompatible with code written by other programmers, which will make your code harder to maintain.

        What I would do is write a C++ class to do your file I/O and use fstream inside that class. The member functions of the class will not expose and fstream code. Then write the rest of your program using only member functions from this class. After your program is working and fully debugged and you still don't like fstream, then return to this class, gut the insides, and replace them with your own FILE* code--if you have the energy and the budget.

        Comment

        • Xillez
          New Member
          • Jul 2013
          • 93

          #5
          within my needs and detail within my program, that header will be MASSIVE. And the amount code used just to read and write to a settings file is insane and I just want a simple and compact way of reading and writing.

          Comment

          • weaknessforcats
            Recognized Expert Expert
            • Mar 2007
            • 9214

            #6
            I'm confused. The size of header files has nothing to do with the size of your program. The only functions that end up in your executable are the ones you called.

            Since each source file is separately compiled you include the complete set of headers in each source file. Massive headers just mean the build takes longer.

            So what you do mean exactly?

            Nothing in a header file allocates memory. The are declarations only.

            Comment

            • Xillez
              New Member
              • Jul 2013
              • 93

              #7
              I just want to know if there is some headers that allow a more efficient (In the amount of code due to a task) then making my own header with the use of fstream's IO

              Comment

              • weaknessforcats
                Recognized Expert Expert
                • Mar 2007
                • 9214

                #8
                A Windows resource is designed to be used by all developers so that all programs work the same. A settings files does not need to be efficient in terms of adding/removing values. It just has to be fast when a program reads the settings.

                I suppose you could start from scratch, design your own settings file and then write code (hopefully no graphic interface code) to manage a file of settings. You might even try coming up with your own parse rules for fetching the settings. Then you could decide to write the management code in either structure or object oriented format. With a 2gz+ processor even the worst code will run liked greased lightning.

                Its reinventing the wheel.

                If you are writing for Windows, then stick with the tools provided in the win32 SDK. Other operating systems have their own preferred settings file format and you should use that on those OSs'.

                Efficiency is not the game these days. A completed program coded in minimum time reusing previously written code is where the action is.

                Comment

                • Xillez
                  New Member
                  • Jul 2013
                  • 93

                  #9
                  ok, thanks for the info... cya later

                  Comment

                  Working...