VirtualBox

source: vbox/trunk/include/iprt/nocrt/iomanip@ 96205

最後變更 在這個檔案從96205是 95993,由 vboxsync 提交於 3 年 前

include/iprt/nocrt: More on ostream, limits. Stubbed std::sort. bugref:10261

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 4.8 KB
 
1/** @file
2 * IPRT / No-CRT - Minimal C++ iomanip header.
3 */
4
5/*
6 * Copyright (C) 2022 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.alldomusa.eu.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef IPRT_INCLUDED_nocrt_iomanip
27#define IPRT_INCLUDED_nocrt_iomanip
28#ifndef RT_WITHOUT_PRAGMA_ONCE
29# pragma once
30#endif
31
32#include <iprt/nocrt/ios>
33
34
35namespace std
36{
37 /**
38 * Used by all flag manipulators.
39 */
40 struct rtNoCrtIosSetFlagsEx
41 {
42 ios_base::fmtflags m_fSet;
43 ios_base::fmtflags m_fMask;
44 };
45
46 template<typename a_CharType, typename a_CharTraits>
47 inline basic_istream<a_CharType, a_CharTraits> &operator>>(basic_istream<a_CharType, a_CharTraits> &a_rSrc,
48 struct rtNoCrtIosSetFlagsEx a_Change)
49 {
50 a_rSrc.setf(a_Change.m_fSet, a_Change.m_fMask);
51 return a_rSrc;
52 }
53
54 template<typename a_CharType, typename a_CharTraits>
55 inline basic_ostream<a_CharType, a_CharTraits> &operator<<(basic_ostream<a_CharType, a_CharTraits> &a_rDst,
56 struct rtNoCrtIosSetFlagsEx a_Change)
57 {
58 a_rDst.setf(a_Change.m_fSet, a_Change.m_fMask);
59 return a_rDst;
60 }
61
62
63 /*
64 * Flag modification functions.
65 */
66
67 inline struct rtNoCrtIosSetFlagsEx setiosflags(ios_base::fmtflags a_fFlags)
68 {
69 struct rtNoCrtIosSetFlagsEx Ret = { a_fFlags, a_fFlags };
70 return Ret;
71 }
72
73 inline struct rtNoCrtIosSetFlagsEx resetiosflags(ios_base::fmtflags a_fFlags)
74 {
75 struct rtNoCrtIosSetFlagsEx Ret = { ios_base::fmtflags(0), a_fFlags };
76 return Ret;
77 }
78
79 inline struct rtNoCrtIosSetFlagsEx setbase(int a_iBase)
80 {
81 struct rtNoCrtIosSetFlagsEx Ret =
82 {
83 a_iBase == 10 ? ios_base::dec
84 : a_iBase == 16 ? ios_base::hex
85 : a_iBase == 8 ? ios_base::oct
86 : ios_base::fmtflags(0),
87 ios_base::basefield
88 };
89 return Ret;
90 }
91
92 /*
93 * Modify precision.
94 */
95 struct rtNoCrtIosSetPrecision
96 {
97 int m_cchPrecision;
98 };
99
100 template<typename a_CharType, typename a_CharTraits>
101 inline basic_istream<a_CharType, a_CharTraits> &operator>>(basic_istream<a_CharType, a_CharTraits> &a_rSrc,
102 struct rtNoCrtIosSetPrecision a_Change)
103 {
104 a_rSrc.precision(a_Change.m_cchPrecision);
105 return a_rSrc;
106 }
107
108 template<typename a_CharType, typename a_CharTraits>
109 inline basic_ostream<a_CharType, a_CharTraits> &operator<<(basic_ostream<a_CharType, a_CharTraits> &a_rDst,
110 struct rtNoCrtIosSetPrecision a_Change)
111 {
112 a_rDst.precision(a_Change.m_cchPrecision);
113 return a_rDst;
114 }
115
116 inline struct rtNoCrtIosSetPrecision setprecision(int a_cchPrecision)
117 {
118 struct rtNoCrtIosSetPrecision Ret = { a_cchPrecision };
119 return Ret;
120 }
121
122 /*
123 * Modify width.
124 */
125 struct rtNoCrtIosSetWidth
126 {
127 int m_cchWidth;
128 };
129
130 template<typename a_CharType, typename a_CharTraits>
131 inline basic_istream<a_CharType, a_CharTraits> &operator>>(basic_istream<a_CharType, a_CharTraits> &a_rSrc,
132 struct rtNoCrtIosSetWidth a_Change)
133 {
134 a_rSrc.width(a_Change.m_cchWidth);
135 return a_rSrc;
136 }
137
138 template<typename a_CharType, typename a_CharTraits>
139 inline basic_ostream<a_CharType, a_CharTraits> &operator<<(basic_ostream<a_CharType, a_CharTraits> &a_rDst,
140 struct rtNoCrtIosSetWidth a_Change)
141 {
142 a_rDst.width(a_Change.m_cchWidth);
143 return a_rDst;
144 }
145
146 inline struct rtNoCrtIosSetWidth setw(int a_cchWidth)
147 {
148 struct rtNoCrtIosSetWidth Ret = { a_cchWidth };
149 return Ret;
150 }
151
152 /** @todo setfil, get_money, set_money, get_time, set_time */
153}
154
155#endif /* !IPRT_INCLUDED_nocrt_iomanip */
156
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette