C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Standard Library types

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Alex J. Dam
Guest





PostPosted: Wed Jan 28, 2004 9:54 pm    Post subject: Standard Library types Reply with quote




Hi,

I'm reposting this since I posted it as an answer and the topic changed a
little (guess no one bothered looking at it).

If I need to store the location of some data within a binary file, in that
same binary file, should I store the pos_type value returned by
ostream::teelp()? (That would be strange. I would be storing extra
information, since I need only the position).

I'm confused as to what types should be used when calling Standard Library
functions, especially when mixing variables of different types, e.g., if I
divide an off_type by a size_t, what do I get?

Thanks.

--
Alex J. Dam
"Oh, I got plenty o' nuttin',
an' nuttin's plenty fo' me"
-- Porgy

Back to top
Victor Bazarov
Guest





PostPosted: Wed Jan 28, 2004 11:04 pm    Post subject: Re: Standard Library types Reply with quote



"Alex J. Dam" <alexjdam (AT) yahoo (DOT) com.br> wrote...
Quote:
If I need to store the location of some data within a binary file, in that
same binary file, should I store the pos_type value returned by
ostream::teelp()? (That would be strange. I would be storing extra
information, since I need only the position).

I'm confused as to what types should be used when calling Standard Library
functions, especially when mixing variables of different types, e.g., if I
divide an off_type by a size_t, what do I get?

I would say, you get off_type. If it's an arithmetic type, a value of
that type retains its type no matter how you slice it or dice it.

My solution was always simpler: since binary files are platform-specific
(in most cases, anyway), then store the position as a long or unsigned
long (or any other type that can accommodate the maximum size of the
file). Once you retrieve it, convert it to the necessary off_type or
pos_type or whatever.

V



Back to top
Jonathan Turkanis
Guest





PostPosted: Thu Jan 29, 2004 3:27 am    Post subject: Re: Standard Library types Reply with quote



"Alex J. Dam" <alexjdam (AT) yahoo (DOT) com.br> wrote

Quote:

Hi,

I'm reposting this since I posted it as an answer and the topic
changed a
little (guess no one bothered looking at it).

If I need to store the location of some data within a binary file,
in that
same binary file, should I store the pos_type value returned by
ostream::teelp()? (That would be strange. I would be storing extra
information, since I need only the position).

I'm confused as to what types should be used when calling Standard
Library
functions, especially when mixing variables of different types,
e.g., if I
divide an off_type by a size_t, what do I get?


Be aware that a stream's pos_type is not an intergral type, although
it can be converted to one. In general, this conversion could loose
information, although this may be unlikely with a stream in binary
mode.

Jonathan



Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.