Easy file IO?

M

mlt

I need to read various .txt files containing application parameteres and
input paths. Are there any good api for this in c++?
 
R

Rui Maciel

mlt said:
I need to read various .txt files containing application parameteres and
input paths. Are there any good api for this in c++?

What do you mean by "good api"? If you are looking for a parser library then there are quite a few out there.
If that's the case then you could look into a small Ini parser I've written in C++, available at:

https://sourceforge.net/projects/minip/


I've also written a small JSON parser in C, which is available at:

https://sourceforge.net/projects/mjson/


Hope this helps,
Rui Maciel
 
J

Jorgen Grahn

I need to read various .txt files containing application parameteres and
input paths. Are there any good api for this in c++?

Yes:

std::string s;
while(std::getline(is, s)) {
// do stuff to the line
}

Almost, but not quite as convenient as Perl's while(<>). If your file
format is 'name=value' or 'name value', just invent a simple
string-splitting/whitespace-trimming function, and feed the parts into
a std::map or whatever.

Someone already suggested his own more specific parser, but if I
recall correctly there are such parsers in Boost, too. There is
nothing in C++ because such file formats tend to be defined by the OS
and/or local conventions.

/Jorgen
 
R

Rune Allnor

I need to read various .txt files containing application parameteres and
input paths. Are there any good api for this in c++?

The regex library might come in handy for parameter
validation. It might be available with your compiler,
or you can use Boost.Regex if it isn't.

Rune
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,159
Messages
2,570,879
Members
47,416
Latest member
LionelQ387

Latest Threads

Top