How to create a tool using C++ to parse XML files [closed] - c++

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I have some XML files that contain different function information. I am trying to create a tool that may extract that information from these files once they are created (function name, arguments number, type, returned values, etc.)
Later i will be manipulating these extracted information to create a new XML file. I have limited programming experience and it's all in C++. Any hint for the start would be appreciated.

If you just want to be able to read and write XML files, its probably just best to use an XML library rather than reinventing the wheel.
Since its not completely clear what you're trying to do, a good place to start would be this thread: What is the best open XML parser for C++? [Stack Overflow]
It's currently closed but it has a couple good answers that will help you figure out the best library to use for your situation.
If you need more help using it, feel free to edit your question, comment, or post a more specific question on the topic.
Happy coding and good luck!

I would suggest TinyXML, it's small, light-weight and suitable in many cases, it also has a non-viral license.
I used it a lot and it was very useful and ... just in case, there's also TinyXPath.

Unless you are doing this as a project to improve your C++ ability and understanding of XML, I would advise against trying to write the parsing code yourself. You will get much faster results using something out there that is already written and well established and there are a number of choices that are open to you. I personally like RapidXML. It is very simple to add to your code (you just need to #include one or two .hpp files - no libraries are needed) and it does everything that I have needed so far which is mainly parsing data from SOAP responses. The site also provides a comprehensive tutorial which enables you to get up and running very quickly.

Related

The best design for a command-line tool [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
It's a simple task, let me briefly describe it!
I'm supposed to code a command-line tool that takes a file-name as an argument, the file
that I'm gonna read consists of lines, each line supposed to be a command to execute, the command is followed by it's appropriate arguments to apply on, to make it clear:
FILE
sum; 1, 2, 3, 4
Output
10
The command-line tool should satisfy those requirements:
1- Easily maintained, developed (more commands might be added in the future) and user-friendly.
2- Command line arguments might be modified and new could be added.
3- Can live as an open-source project, an organised source-tree.
I'm expecting developers to deal with the source-code and fairly understand it.
I'm a newbie in those stuff, I'm kinda new to design patterns so I don't know much, I wanna follow the best practices in developing this program, I really wanna use design patterns if applicable and make my code better and cleaner, so please advise and guide me to write this tool in the best possible way, I don't wanna write dirty code, I wanna write a high-quality code that does what it's intended to and could be easily developed further.
Please advise and feel free to criticize what I've just said.
One last thing, I'll be using C++!
Thanks!
1- Boost.Program_options is your friend when it comes to parsing command line options.
2- Take a look at the command pattern. Although it is easier to implement in language that has reflection facilities, it is still possible to have a map of "command strings" mapped to function. Please use C++11 facilities for this. i.e. std::function.
3- There is no standard structure for C++ projects. Personally, I use Boost's recommended structure.

Best c++ method to store small amounts of data for later use [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I need to store a small amount of data (between 1 and 5 characters) and I would like to know the best way to go about doing it.
I need to be able to read it when the application first starts and if the file doesn't exist, create it and save data to it (or if it does exist, read the data and put it in a variable).
Any guidance and code examples given on any of these problems will be greatly appreciated.
You'll need to write and read your data from a file. If you want to find out how to read and write files in C++ you can try the following tutorial:
http://www.cplusplus.com/doc/tutorial/files/
For the file management you could use fstream. (Aka, ifstream, ofstream, etc)
Just create a file and write the data. That's pretty much the only way to go about it.
write to files using fstream
if the data could be sorted into key/value tuples you could also use the windows registery
If you're using Windows you can use the Windows Registry (look it up in the Visual Studio docs). I don't necessarily recommend that, a file may be more convenient, but it is a standard Windows technique.

Mallet vs Weka for text classification [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
Which product (Mallet or Weka) is better for text classification task:
Simpler to train
Better results
Documentation
I'm new for this problem so any comments will be great
MALLET is much easier to use and does most of its job invisibly. You don't have to convert the format of anything either, you just give it text files and it gives you back results.
Weka requires converting the text into a particular format (the Weka script for doing so it so slow and inefficient that I would recommend you write your own).
The problem with MALLET is that the training uses GB of memory and it can take hours, if you have large training sets.
Weka has more documentation, but most of it makes no sense. MALLET has very little documentation but is very simple to use.
To be honest, after testing the both of them, I opted for writing my own classifier.
I'm really enjoying Weka vs Mallet. Maybe I don't know enough yet, but doing machine learning with a GUI is awesome. You can tweak parameters and run different experiments (keeping the results of past experiments in front of you, too) very easily. I'm new to Weka, so this is FWIW.
As far as which one is simpler to train, I find Weka simpler. I don't know what kind of control you can have over your feature space by just pointing Mallet at some text (maybe it's good enough), but my experience with Mallet was comparable to Weka... writing scripts to get the input in the proper format, with the caveat that I had to do multiple steps to utilize some kind of serialized version of the data in Mallet.
Regarding your other questions, I can't really answer them right now, but am hoping this answer doesn't get downvoted 'cause it's good information to be out there, anyway.

Useful features to learn in boost for immediate use [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I know this could be seen as subjective off-the-cuff (thus a poor question), but bear with me.
Boost has recently become available on the project on which I'm working, and I don't have much experience with it. Boost has so many parts and features that it's hard to know where to get started in learning it - especially since I'll be trying to learn it while making production code.
So, I would greatly appreciate it if someone could list around 3 to 5 features which are very useful in general, every-day programming and state why they're useful. I'm not asking you which is best, or trying to get a debate - I just want to know some good features to start learning and using immediately. I don't need code samples either, I'll be more than happy to research how to use the features myself after I know which ones are sensible to start learning now.
I'll accept any answer with a concise list of features that are sensible :)
format and lexical_cast are great for string manipulation, I find them invaluable. I use them every day.
bind is great for ad hoc functors, you'll find it is reused throughout many of the boost libraries.
multi_index fills the gap of when you need the same data in two search structures at once, it is very handy at times. Keep it out of your headers though.
type_traits defines useful traits for template specializations.
signals is a signal/slot mechanism implementation, great for event driven designs.
shared_pointer is critical. It lets you automatically handle memory usage.
http://www.boost.org/doc/libs/1_47_0/libs/smart_ptr/shared_ptr.htm

Best/Most Comprehensive API for Stocks/Financial Data [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
What is the most recommended free/public API for accessing financial market stats and stock quotes (preferrably real-time quotes)? I'm not too picky about how it's exposed (SOAP, REST, some proprietary XML setup, etc.), as long as it's got some decent documentation.
I'm planning to build a simple web dashboard in PHP with some basic data (basically a quick-n-dirty homepage), but may want to grow it into a full blown web app eventually. Any thoughts?
As I find some, I'll post a list here (feel free to comment if you've used any of them before):
Free
opentick (soprano) // link doesn't work
Not Free
XigniteRealTime
Yahoo's api provides a CSV dump:
Example: http://finance.yahoo.com/d/quotes.csv?s=msft&f=price
I'm not sure if it is documented or not, but this code sample should showcase all of the features (namely the stat types [parameter f in the query string]. I'm sure you can find documentation (official or not) if you search for it.
http://www.goldb.org/ystockquote.html
Edit
I found some unofficial documentation:
http://ilmusaham.wordpress.com/tag/stock-yahoo-data/
I usually find that ProgrammableWeb is a good place to go when looking for APIs.
Markit On Demand provides a set of free financial APIs for playing around with. Looks like there is a stock quote API, a stock ticker/company search and a charting API available. Look at http://dev.markitondemand.com
Last I looked -- a couple of years ago -- there wasn't an easy option and the "solution" (which I did not agree with) was screen-scraping a number of websites. It may be easier now but I would still be surprised to see something, well, useful.
The problem here is that the data is immensely valuable (and very expensive), so while defining a method of retrieving it would be easy, getting the trading venues to part with their data would be next to impossible. Some of the MTFs (currently) provide their data for free but I'm not sure how you would get it without paying someone else, like Reuters, for it.
I found the links and tips under this question to be helpful.
Some of the brokerage firms like TDAmeritrade have APIs you can use to get streaming data from their servers:
http://www.tdameritrade.com/tradingtools/partnertools/api_dev.html