source:
Revenant/marslib/src/mars_streams.cpp@
71dea59
Last change on this file since 71dea59 was 71dea59, checked in by , 4 years ago | |
---|---|
|
|
File size: 732 bytes |
Line | |
---|---|
1 | #include "mars_streams.h" |
2 | |
3 | #include <stdio.h> |
4 | #include <assert.h> |
5 | |
6 | namespace mars |
7 | { |
8 | ObjectStream::ObjectStream (std::iostream * pIO) : _pIn(pIO), _pOut(pIO), _traits(determineTraits()) |
9 | {} |
10 | |
11 | ObjectStream::ObjectStream (std::istream * pIn) : _pIn(pIn), _traits(determineTraits()) |
12 | {} |
13 | |
14 | ObjectStream::ObjectStream (std::ostream * pOut) : _pOut(pOut), _traits(determineTraits()) |
15 | {} |
16 | |
17 | ObjectStream::Traits ObjectStream::determineTraits() |
18 | { |
19 | unsigned long l = 1; |
20 | Traits traits; |
21 | |
22 | // TODO: Verify endian algorithm is correct and works for memory detection, might require disk access instead |
23 | if (*reinterpret_cast< char * > (&l) & 1) |
24 | traits.endian = Traits::Little; |
25 | else |
26 | traits.endian = Traits::Big; |
27 | |
28 | return traits; |
29 | } |
30 | } |
Note:
See TracBrowser
for help on using the repository browser.