/usr/include/omniORB4/streamOperators.h is in libomniorb4-dev 4.1.6-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 | // -*- Mode: C++; -*-
// Package : omniORB
// streamOperators.h Created on: 2006/05/23
// Author : Duncan Grisby
//
// Copyright (C) 2006 Apasphere Ltd.
//
// This file is part of the omniORB library
//
// The omniORB library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free
// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA
//
//
// Description:
// Stream operators
//
// $Id: streamOperators.h 5498 2006-05-25 18:16:50Z dgrisby $
/*
$Log$
*/
#ifndef __OMNI_STREAM_OPERATORS_H__
#define __OMNI_STREAM_OPERATORS_H__
#include <string>
#include <iostream>
#include <cctype>
#ifdef minor
// Can you believe some compilers #define this...
# undef minor
#endif
inline std::istream& operator>>(std::istream& is,
CORBA::String_var& val)
{
std::string s;
if (is >> s)
val = (const char*)s.c_str();
return is;
}
inline std::ostream& operator<<(std::ostream& os,
const CORBA::String_var& val)
{
os << (const char*)val;
return os;
}
inline std::istream& operator>>(std::istream& is,
CORBA::String_out& val)
{
std::string s;
if (is >> s)
val = (const char*)s.c_str();
return is;
}
inline std::ostream& operator<<(std::ostream& os,
const CORBA::String_out& val)
{
os << (const char*)val._data;
return os;
}
inline std::istream& operator>>(std::istream& is,
CORBA::String_member& val)
{
std::string s;
if (is >> s)
val = (const char*)s.c_str();
return is;
}
inline std::ostream& operator<<(std::ostream& os,
const CORBA::String_member& val)
{
os << (const char*)val;
return os;
}
inline std::istream& operator>>(std::istream& is,
_CORBA_String_element& val)
{
std::string s;
if (is >> s)
val = (const char*)s.c_str();
return is;
}
inline std::ostream& operator<<(std::ostream& os,
const _CORBA_String_element& val)
{
os << (const char*)val;
return os;
}
inline std::istream& operator>>(std::istream& is,
CORBA::Fixed& val)
{
if (!is.good())
return is;
char buf[34]; // plus/minus, up to 31 digits and a decimal point,
// plus terminating null
char* c = buf;
char* end = buf + sizeof(buf) - 3;
int decimal = 0;
is >> *c; // Get first char, skipping white space
if (*c == '+' || *c == '-') {
++c; ++end; *c = is.get();
}
if (*c == '.') {
decimal = 1;
++c; *c = is.get();
}
if (!isdigit(*c)) {
is.putback(*c);
is.setstate(std::ios_base::failbit);
return is;
}
while (++c != end + decimal) {
*c = is.get();
if (*c == '.') {
if (decimal) {
is.putback(*c);
break;
}
else {
decimal = 1;
}
}
else if (!isdigit(*c)) {
is.putback(*c);
break;
}
}
*c = '\0';
val.NP_fromString(buf);
return is;
}
inline std::ostream& operator<<(std::ostream& os,
const CORBA::Fixed& val)
{
// The C++ mapping says that this should always obey the stream's
// precision, but never use scientific notation. Since the default
// precision is 6, that would mean that by default any fixed value
// larger than six digits would be shown as an integer, which would
// not be what most people expect. What we do here is leave the
// fixed value as-is unless the format flags are set to fixed, in
// which case we round to the precision.
CORBA::String_var s;
if (os.flags() & std::ios_base::fixed) {
CORBA::Fixed rounded = val.round(os.precision());
rounded.PR_setLimits(31-os.precision(), os.precision());
s = rounded.to_string();
}
else {
s = val.NP_asString();
}
os << s;
return os;
}
inline std::ostream& operator<<(std::ostream& os,
const CORBA::Exception* ex)
{
const CORBA::SystemException* sex = CORBA::SystemException::_downcast(ex);
if (sex) {
os << "CORBA::" << sex->_name() << "(";
const char* minor = sex->NP_minorString();
if (minor)
os << minor;
else {
std::ios_base::fmtflags flags = os.flags();
os << "0x" << std::hex << sex->minor();
os.flags(flags);
}
os << ", CORBA::";
switch (sex->completed()) {
case CORBA::COMPLETED_YES:
os << "COMPLETED_YES";
break;
case CORBA::COMPLETED_NO:
os << "COMPLETED_NO";
break;
default:
os << "COMPLETED_MAYBE";
}
os << ")";
}
else {
os << "User exception: " << ex->_rep_id();
}
return os;
}
inline std::ostream& operator<<(std::ostream& os,
const CORBA::Exception& ex)
{
return os << &ex;
}
#ifdef OMNI_WIDE_STREAM_OPERATORS
inline std::wistream& operator>>(std::wistream& is,
CORBA::WString_var& val)
{
std::wstring s;
if (is >> s)
val = (const CORBA::WChar*)s.c_str();
return is;
}
inline std::wostream& operator<<(std::wostream& os,
const CORBA::WString_var& val)
{
os << (const CORBA::WChar*)val;
return os;
}
inline std::wistream& operator>>(std::wistream& is,
CORBA::WString_out& val)
{
std::wstring s;
if (is >> s)
val = (const CORBA::WChar*)s.c_str();
return is;
}
inline std::wostream& operator<<(std::wostream& os,
const CORBA::WString_out& val)
{
os << (const CORBA::WChar*)val._data;
return os;
}
inline std::wistream& operator>>(std::wistream& is,
CORBA::WString_member& val)
{
std::wstring s;
if (is >> s)
val = (const CORBA::WChar*)s.c_str();
return is;
}
inline std::wostream& operator<<(std::wostream& os,
const CORBA::WString_member& val)
{
os << (const CORBA::WChar*)val;
return os;
}
inline std::wistream& operator>>(std::wistream& is,
_CORBA_WString_element& val)
{
std::wstring s;
if (is >> s)
val = (const CORBA::WChar*)s.c_str();
return is;
}
inline std::wostream& operator<<(std::wostream& os,
const _CORBA_WString_element& val)
{
os << (const CORBA::WChar*)val;
return os;
}
#endif // OMNI_WIDE_STREAM_OPERATORS
#endif // __OMNI_STREAM_OPERATORS_H__
|