summaryrefslogtreecommitdiffstats
path: root/private/crt32/iostream/ostruint.cxx
blob: f528fcc636be12bb59a4c9250cd80463884415fb (plain) (blame)
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
/***
* ostruint.cxx - definitions for ostream class operator<<(unsigned int) funct
*
*	Copyright (c) 1991-1992, Microsoft Corporation.  All rights reserved.
*
*Purpose:
*	Contains the member function definitions for ostream
*	operator<<(unsigned int).
*
*Revision History:
*	09-23-91   KRS	Created.  Split out from ostream.cxx for granularity.
*
*******************************************************************************/

#include <cruntime.h>
#include <internal.h>
#include <stdio.h>
#include <iostream.h>
#pragma hdrstop

ostream& ostream::operator<<(unsigned int n)
{
_WINSTATIC char obuffer[12];
_WINSTATIC char fmt[4] = "%u";
_WINSTATIC char leader[4] = "\0\0";
    if (opfx()) {
	if (n) 
	    {
            if (x_flags & (hex|oct))
		{
		if (x_flags & hex)
		    {
		    if (x_flags & uppercase) 
			fmt[1] = 'X';
		    else
			fmt[1] = 'x';
		    leader[1] = fmt[1];   // 0x or 0X  (or \0X)
		    }
		else
		    fmt[1] = 'o';
		if (x_flags & showbase)
	            leader[0] = '0';
		}
	    else if (x_flags & showpos)
		{
		leader[0] = '+';
		}
	    }
	sprintf(obuffer,fmt,n);
	writepad(leader,obuffer);
	osfx();
    }
    return *this;

}