Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » How to load only header of the file with LoadFromFile?
How to load only header of the file with LoadFromFile? [message #19740] Thu, 08 January 2009 20:22 Go to previous message
White_Owl is currently offline  White_Owl
Messages: 27
Registered: January 2009
Location: New York
Promising Member
I have a pretty big data file with a lot of data.
I need to show list of my data files. So I'd like to read only headers of my data file and ignore actual data.

Right now I see two ways:
1) Modify all LoadFrom*() functions, to add the third parameter bool header=false. And add to Stream function IsHeader();
That would be pretty universal, but a lot of work.

2) Solution "for right now":
class MyData {
public:
   bool header_only;
   String data_description;

   void Serialize(Stream &s) {
      s % data_description;
      if(s.IsLoading() && header_only) return;
      s % data1 % data2 % data3 ;
   }
};
.....
MyData d;
d.header_only = true;
LoadFromFile(d, file_name);


Is there a third more elegant way?
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: GetUserName fails on WinXP/MinGW
Next Topic: Quick bi-array
Goto Forum:
  


Current Time: Wed May 15 10:04:49 CEST 2024

Total time taken to generate the page: 0.02371 seconds