May 20, 2013 at 10:42am UTC
While using Microsoft Visual Studio 2010, there's a class _Iosb within <xiosbase>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
// TEMPLATE CLASS _Iosb
template <class _Dummy>
class _Iosb
{ // define templatized bitmask/enumerated types, instantiate on demand
public :
enum _Dummy_enum {_Dummy_enum_val = 1}; // don't ask
enum _Fmtflags
{ // constants for formatting options
_Fmtmask = 0xffff, _Fmtzero = 0};
static const _Fmtflags skipws = (_Fmtflags)_IOSskipws;
static const _Fmtflags unitbuf = (_Fmtflags)_IOSunitbuf;
static const _Fmtflags uppercase = (_Fmtflags)_IOSuppercase;
static const _Fmtflags showbase = (_Fmtflags)_IOSshowbase;
static const _Fmtflags showpoint = (_Fmtflags)_IOSshowpoint;
static const _Fmtflags showpos = (_Fmtflags)_IOSshowpos;
static const _Fmtflags left = (_Fmtflags)_IOSleft;
static const _Fmtflags right = (_Fmtflags)_IOSright;
static const _Fmtflags internal = (_Fmtflags)_IOSinternal;
static const _Fmtflags dec = (_Fmtflags)_IOSdec;
static const _Fmtflags oct = (_Fmtflags)_IOSoct;
static const _Fmtflags hex = (_Fmtflags)_IOShex;
static const _Fmtflags scientific = (_Fmtflags)_IOSscientific;
static const _Fmtflags fixed = (_Fmtflags)_IOSfixed;
static const _Fmtflags hexfloat =
(_Fmtflags)_IOShexfloat; // added with TR1/
static const _Fmtflags boolalpha = (_Fmtflags)_IOSboolalpha;
static const _Fmtflags _Stdio = (_Fmtflags)_IOS_Stdio;
static const _Fmtflags adjustfield = (_Fmtflags)(_IOSleft
| _IOSright | _IOSinternal);
static const _Fmtflags basefield = (_Fmtflags)(_IOSdec
| _IOSoct | _IOShex);
static const _Fmtflags floatfield = (_Fmtflags)(_IOSscientific
| _IOSfixed);
enum _Iostate
{ // constants for stream states
_Statmask = 0x17};
static const _Iostate goodbit = (_Iostate)0x0;
static const _Iostate eofbit = (_Iostate)0x1;
static const _Iostate failbit = (_Iostate)0x2;
static const _Iostate badbit = (_Iostate)0x4;
static const _Iostate _Hardfail = (_Iostate)0x10;
enum _Openmode
{ // constants for file opening options
_Openmask = 0xff};
static const _Openmode in = (_Openmode)0x01;
static const _Openmode out = (_Openmode)0x02;
static const _Openmode ate = (_Openmode)0x04;
static const _Openmode app = (_Openmode)0x08;
static const _Openmode trunc = (_Openmode)0x10;
static const _Openmode _Nocreate = (_Openmode)_IOS_Nocreate;
static const _Openmode _Noreplace = (_Openmode)_IOS_Noreplace;
static const _Openmode binary = (_Openmode)_IOSbinary;
enum _Seekdir
{ // constants for file positioning options
_Seekmask = 0x3};
static const _Seekdir beg = (_Seekdir)0;
static const _Seekdir cur = (_Seekdir)1;
static const _Seekdir end = (_Seekdir)2;
enum
{ // constant for default file opening protection
_Openprot = _OPENPROT};
};
The class itself is pretty easy to understand, but after the class the following lines of code are present-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
template <class _Dummy>
const typename _Iosb<_Dummy>::_Fmtflags _Iosb<_Dummy>::skipws;
template <class _Dummy>
const typename _Iosb<_Dummy>::_Fmtflags _Iosb<_Dummy>::unitbuf;
template <class _Dummy>
const typename _Iosb<_Dummy>::_Fmtflags _Iosb<_Dummy>::uppercase;
template <class _Dummy>
const typename _Iosb<_Dummy>::_Fmtflags _Iosb<_Dummy>::showbase;
template <class _Dummy>
const typename _Iosb<_Dummy>::_Fmtflags _Iosb<_Dummy>::showpoint;
template <class _Dummy>
const typename _Iosb<_Dummy>::_Fmtflags _Iosb<_Dummy>::showpos;
template <class _Dummy>
const typename _Iosb<_Dummy>::_Fmtflags _Iosb<_Dummy>::left;
template <class _Dummy>
const typename _Iosb<_Dummy>::_Fmtflags _Iosb<_Dummy>::right;
template <class _Dummy>
const typename _Iosb<_Dummy>::_Fmtflags _Iosb<_Dummy>::internal;
template <class _Dummy>
const typename _Iosb<_Dummy>::_Fmtflags _Iosb<_Dummy>::dec;
template <class _Dummy>
const typename _Iosb<_Dummy>::_Fmtflags _Iosb<_Dummy>::oct;
template <class _Dummy>
const typename _Iosb<_Dummy>::_Fmtflags _Iosb<_Dummy>::hex;
template <class _Dummy>
const typename _Iosb<_Dummy>::_Fmtflags _Iosb<_Dummy>::scientific;
template <class _Dummy>
const typename _Iosb<_Dummy>::_Fmtflags _Iosb<_Dummy>::fixed;
template <class _Dummy>
const typename _Iosb<_Dummy>::_Fmtflags
_Iosb<_Dummy>::hexfloat; // added with TR1
template <class _Dummy>
const typename _Iosb<_Dummy>::_Fmtflags _Iosb<_Dummy>::boolalpha;
template <class _Dummy>
const typename _Iosb<_Dummy>::_Fmtflags _Iosb<_Dummy>::_Stdio;
template <class _Dummy>
const typename _Iosb<_Dummy>::_Fmtflags _Iosb<_Dummy>::adjustfield;
template <class _Dummy>
const typename _Iosb<_Dummy>::_Fmtflags _Iosb<_Dummy>::basefield;
template <class _Dummy>
const typename _Iosb<_Dummy>::_Fmtflags _Iosb<_Dummy>::floatfield;
template <class _Dummy>
const typename _Iosb<_Dummy>::_Iostate _Iosb<_Dummy>::goodbit;
template <class _Dummy>
const typename _Iosb<_Dummy>::_Iostate _Iosb<_Dummy>::eofbit;
template <class _Dummy>
const typename _Iosb<_Dummy>::_Iostate _Iosb<_Dummy>::failbit;
template <class _Dummy>
const typename _Iosb<_Dummy>::_Iostate _Iosb<_Dummy>::badbit;
template <class _Dummy>
const typename _Iosb<_Dummy>::_Iostate _Iosb<_Dummy>::_Hardfail;
template <class _Dummy>
const typename _Iosb<_Dummy>::_Openmode _Iosb<_Dummy>::in;
template <class _Dummy>
const typename _Iosb<_Dummy>::_Openmode _Iosb<_Dummy>::out;
template <class _Dummy>
const typename _Iosb<_Dummy>::_Openmode _Iosb<_Dummy>::ate;
template <class _Dummy>
const typename _Iosb<_Dummy>::_Openmode _Iosb<_Dummy>::app;
template <class _Dummy>
const typename _Iosb<_Dummy>::_Openmode _Iosb<_Dummy>::trunc;
template <class _Dummy>
const typename _Iosb<_Dummy>::_Openmode _Iosb<_Dummy>::_Nocreate;
template <class _Dummy>
const typename _Iosb<_Dummy>::_Openmode _Iosb<_Dummy>::_Noreplace;
template <class _Dummy>
const typename _Iosb<_Dummy>::_Openmode _Iosb<_Dummy>::binary;
template <class _Dummy>
const typename _Iosb<_Dummy>::_Seekdir _Iosb<_Dummy>::beg;
template <class _Dummy>
const typename _Iosb<_Dummy>::_Seekdir _Iosb<_Dummy>::cur;
template <class _Dummy>
const typename _Iosb<_Dummy>::_Seekdir _Iosb<_Dummy>::end;
What do these lines of code do?
P.S. - I am pretty new to programming and this forum, so if this topic is in the wrong subforum(?) please forgive me.
Thanks,
base evil.
Last edited on May 20, 2013 at 10:43am UTC
May 20, 2013 at 3:29pm UTC
Judging from underscore followed by capital letter, this is internal class used by implementation and does not intendet to be used by end-user. Looks like it is defines flags you usually access as ios::in , ios::out , ios::ate and others.
May 20, 2013 at 4:50pm UTC
Sorry, I did not word my question properly-
Revised question-
Isn't the definition in the class?(See the first block of code.)
Correct me if I am wrong but isn't the first block Creating the flags?
Then the second block is referring to them, with their type ("_Iosb<_Dummy>") in front? (const typename className::Enum1 className::ObjectWithTypeEnum1;)
The last part of the line "className::ObjectWithTypeEnum1" is referring to the flags created in the class.
As far as I know you don't refer to objects with their type in front of them.
Last edited on May 20, 2013 at 4:53pm UTC
May 20, 2013 at 10:38pm UTC
Edit: On re-reading, the post I thought might be interesting (now below), I'm not so sure it's interesting.
- The static const values are being declared and initialized inside the class, but not defined.
- The lines after the class are then defining them but not re-initializing them.
And all these members are enum value (i.e. some sort of integer, depending on what the compiler choses to use.)
Andy
This post might be of interest: Not so interesting post
static variable in the class declaration or definition?
http://stackoverflow.com/questions/11178434/static-variable-in-the-class-declaration-or-definition
Last edited on May 21, 2013 at 12:08am UTC