Thanks for showing copy - I was wondering if that might work.
Given this case where the header is in the first 5 rows, can we use getline to read those, then use copy to pull in the rest?
Hi I think we more or less agree the istringstream class is real *SLOW*. So yes to make it fast, we need to avoid using that and switch to alternatives like what you suggest getline from iostream I believe ?
I do more testing myself yesterday and it *seems* the C++ iostream do "lose-out" to C stdio in terms of raw performance when data gets more say 1 million or more. I have no stats to back me up but I wait for rocketboy9000 to come out with another test program that measure C++ iostream vs C stdio :P
In the meantime, a simple strategy would be we can use C stdio to do massive read or write I/O activities into C++ containers, algorithms, iterators etc provided to do our in-memory operations.
The code so far is probably not a very good test. As far as I know, istringstream will make a copy of the string it is given, which is a non-trivial amount of time, given the size of the string. I don't have time to test this right now.
I generally don't have any use for istringstream. Most of the time, such data is going to be in a file, where you should read it directly (stream >> var;) rather than making multiple copies. If it isn't in a file, then it is often as a const char* (arguments passed in and such), where it just makes more sense to to use c-style functions taking character pointers rather than useless conversions to strings.
I have run into a lot of places where people copy a char* into a string just to pass it into another function as a char* with c_str().
I wait for rocketboy9000 to come out with another test program that measure C++ iostream vs C stdio :P
I'm doing that, actually, but I need an equivalent to the following call: scanf("%100[^\n]\n",s);
Is there a way to do this using cin >>, or do I have to use getline?
EDIT: I need it to match the last element of the output lines from this perl script:
1 2 3
do{
print join " ",(int rand(2**16)-2**15-1,int rand(2**32)-2**31-1,sprintf("%x",(int rand 2**32)),rand(),rand(1000)/rand(1000),chr rand(95)+32,"butter","The rest of this line!!!"),"\n";
}until($x++==100000)
Getline works perfectly, but I'm wondering if there is a more scanf-like way.
Now your latest test seem to indicate the Standard C++ istringstream implementation need some investigation. If istream performance is comparable to C stdio why isn't istringstream exhibit-ing the same performance characteristics?
Maybe Bjarne Strostrup aka C++ creator know the answer ?
About the firs part of the file, I just wrote a little code that should be use.
Maybe it should be useful for some other people that work with ArcGis files...