Home
Install
Use
Develop
Support
News
Credits
hosted by
|
33Parent* factory (FILE* fptr)
35 long current = ftell (fptr);
37 std::vector< Reference::To<Parent> > candidates;
39 Parent::children (candidates);
41 for ( unsigned i=0; i < candidates.size(); i++) {
43 if (fseek (fptr, current, SEEK_SET) < 0)
44 throw Error (FailedSys, "factory (FILE*)", "fseek");
47 candidates[i]->load (fptr);
48 return candidates[i].release();
50 catch ( Error& error) { }
53 throw Error (InvalidParam, "factory (FILE*)",
54 "no child recognizes contents of file");
58Parent* factory (FILE* fptr, size_t nbytes)
62 throw Error (FailedSys, "factory (FILE*, size_t)", "tmpfile");
64 ::copy (fptr, temp, nbytes);
67 return factory<Parent> (temp);
71Parent* factory ( const std::string& filename)
73 std::string use_filename = expand (filename);
75 FilePtr temp = fopen (use_filename.c_str(), "r");
77 throw Error (FailedSys, "factory (std::string&)",
78 "fopen (%s)", use_filename.c_str());
80 return factory<Parent> (temp);
88Any* load ( const std::string& filename)
90 std::string use_filename = expand (filename);
92 FilePtr temp = fopen (use_filename.c_str(), "r");
94 throw Error (FailedSys, "Any* load (std::string&)",
95 "fopen (%s)", use_filename.c_str());
103size_t nbytes ( const Any* any)
107 throw Error (FailedSys, "nbytes (Any*)", "tmpfile");
A convenient exception handling class. Definition Error.h:54
Closes a FILE* when it goes out of scope. Definition FilePtr.h:19
Generated using doxygen 1.14.0
|