17

I have to write an xml configuration parser for an in-house data acquisition system that I've been tasked with developing.

I hate doing string parsing in C++... Blegh!

Comments
  • 0
    Arent there existing c++ xml-parsers out there? Or do you need a special feature?
  • 0
    I can't use external libraries. Everything has to be from scratch 😧
  • 1
    @Gogeta70 what good reason could there ever be to not use an existing xml-parser?
  • 0
    @YouAreAPIRate Licensing. The company wants full ownership of the software without any legal issues relating to software licensing.
  • 3
    @Gogeta70 i did a quick search, there are some lgpl- or boost-licensed libraries. I'm no expert at that, but choosing one of those and checking the license should be faster than writing, testing and bugfixing your code.
  • 0
    @YouAreAPIRate Yeah, I know but the decision is from above my head, not much I can do. Plus I'm already halfway done with it. It's a fairly easy task overall, just a bit meticulous...
  • 1
    @meltdown Yeah, and I wouldn't have it any other way :P

    I love C++
  • 3
    @YouAreAPIRate
    Or you can just get a BSD or MIT licensed one, change one line of code, and declare it your own.

    "Due to the extremely minimal restrictions of BSD-style licenses, software released under such licenses can be freely modified and used in proprietary (i.e., commerical) software for which the source code is kept secret." (http://linfo.org/bsdlicense.html/)
  • 0
    @Zennoe Well, to be honest, I've been writing C++ for almost 15 years. I simply prefer the way it's been done for so long, and I'm pretty damn good at avoiding memory leaks doing it this way. So I see no need to change my coding style simply because a new language feature was added. I do like lambda functions though.
  • 1
    @Zennoe I guess I'm old-school... I don't use Valgrind or any other tools to profile my code. Essentially, I keep my code organized into easily understood and readable "blocks" - no function should perform super-complex tasks that are hard to follow. The code above is incomplete - mostly uncommented, and a big, confusing block of code. When it's done, I'll break it down into smaller private methods. As for memory leaks, I've run into a few here and there, but my general rule of thumb is to always allocate and free memory in the same layer of code. It keeps things easy to track mentally. Also, I monitor memory usage when I run my software to see if it's slowly increasing.

    So, my method is be careful, be organized, and triple-check what your code is doing. :)
  • 1
    @Zennoe Another thing... I've seen a lot of people get caught up in IDE's, compilers, profilers, etc etc. The whole point of being a programmer is to write code, not use tools.

    As long as you write clean, efficient code that is readable and can be easily modified or built upon, nothing else matters so much. Just enjoy writing the code your way.
  • 0
    @Gogeta70
    I agree, which is exactly why you shouldn't use IDEs /s
  • 0
    @tiberius1900 I'm not saying don't use IDE's, hell I used codeblocks for a long time. Just don't get caught up choosing a tool.
  • 0
    @Gogeta70
    I know, hence the "/s"
  • 0
    @tiberius1900 Eh... I missed that, lol. Sarcasm is hard to detect on the interwebz :P
  • 0
    No state-machine?
Add Comment