SystemC 3.0.0
Accellera SystemC proof-of-concept library
sc_string.h
Go to the documentation of this file.
1/*****************************************************************************
2
3 Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
4 more contributor license agreements. See the NOTICE file distributed
5 with this work for additional information regarding copyright ownership.
6 Accellera licenses this file to you under the Apache License, Version 2.0
7 (the "License"); you may not use this file except in compliance with the
8 License. You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
15 implied. See the License for the specific language governing
16 permissions and limitations under the License.
17
18 *****************************************************************************/
19
20/*****************************************************************************
21
22 sc_string.h -- Implementation of a simple string class.
23
24 Original Author: Stan Y. Liao, Synopsys, Inc.
25
26 CHANGE LOG AT END OF FILE
27 *****************************************************************************/
28
29// $Log: sc_string.h,v $
30// Revision 1.3 2011/08/26 20:46:19 acg
31// Andy Goodrich: moved the modification log to the end of the file to
32// eliminate source line number skew when check-ins are done.
33//
34#ifndef SC_STRING_H
35#define SC_STRING_H
36
37
40#include <iostream>
41
42// For legacy code using sc_string:
43#ifdef SC_USE_STD_STRING
44typedef ::std::string sc_string;
45#endif // SC_USE_STD_STRING
46
47namespace sc_dt {
48
49// ----------------------------------------------------------------------------
50// ENUM : sc_numrep
51//
52// Enumeration of number representations for character string conversion.
53// ----------------------------------------------------------------------------
54
56{
58 SC_BIN = 2,
59 SC_OCT = 8,
60 SC_DEC = 10,
61 SC_HEX = 16,
68 SC_CSD
69};
70
71// We use typedefs for istream and ostream here to get around some finickiness
72// from aCC:
73
74typedef ::std::istream systemc_istream;
75typedef ::std::ostream systemc_ostream;
76
77const std::string to_string( sc_numrep );
78
79//------------------------------------------------------------------------------
80//"sc_io_base"
81//
82// This inline function returns the type of an i/o stream's base as a SystemC
83// base designator.
84// stream_object = reference to the i/o stream whose base is to be returned.
85//
86//"sc_io_show_base"
87//
88// This inline function returns true if the base should be shown when a SystemC
89// value is displayed via the supplied stream operator.
90// stream_object = reference to the i/o stream to return showbase value for.
91//------------------------------------------------------------------------------
92#if defined(__GNUC__) || defined(_MSC_VER)
93 inline sc_numrep sc_io_base( systemc_ostream& stream_object,
94 sc_numrep def_base )
95 {
97 stream_object.flags() & ::std::ios::basefield;
98 if ( flags & ::std::ios::dec ) return SC_DEC;
99 if ( flags & ::std::ios::hex ) return SC_HEX;
100 if ( flags & ::std::ios::oct ) return SC_OCT;
101 return def_base;
102 }
103 inline bool sc_io_show_base( systemc_ostream& stream_object )
104 {
105 return (stream_object.flags() & ::std::ios::showbase) != 0 ;
106 }
107#else // Other
108 inline sc_numrep sc_io_base( systemc_ostream& stream_object,
109 sc_numrep def_base )
110 {
111 return SC_DEC;
112 }
113 inline bool sc_io_show_base( systemc_ostream& stream_object )
114 {
115 return false;
116 }
117#endif
118
119
120} // namespace sc_dt
121
122// Revision 1.2 2011/02/18 20:38:44 acg
123// Andy Goodrich: Updated Copyright notice.
124//
125// Revision 1.1.1.1 2006/12/15 20:20:06 acg
126// SystemC 2.3
127//
128// Revision 1.4 2006/05/08 17:50:51 acg
129// Andy Goodrich: added David Long's forward declarations for friend
130// functions, methods, and operators to keep the Microsoft compiler happy.
131//
132// Revision 1.3 2006/01/13 18:53:11 acg
133// Andy Goodrich: Added $Log command so that CVS comments are reproduced in
134// the source.
135//
136
137#endif
::std::string sc_string
Definition: systemc.h:298
::std::ostream systemc_ostream
Definition: sc_string.h:75
sc_numrep sc_io_base(systemc_ostream &stream_object, sc_numrep def_base)
Definition: sc_string.h:108
bool sc_io_show_base(systemc_ostream &stream_object)
Definition: sc_string.h:113
sc_numrep
Definition: sc_string.h:56
@ SC_CSD
Definition: sc_string.h:68
@ SC_HEX_SM
Definition: sc_string.h:67
@ SC_OCT_US
Definition: sc_string.h:64
@ SC_BIN
Definition: sc_string.h:58
@ SC_HEX
Definition: sc_string.h:61
@ SC_BIN_US
Definition: sc_string.h:62
@ SC_NOBASE
Definition: sc_string.h:57
@ SC_BIN_SM
Definition: sc_string.h:63
@ SC_OCT_SM
Definition: sc_string.h:65
@ SC_OCT
Definition: sc_string.h:59
@ SC_HEX_US
Definition: sc_string.h:66
@ SC_DEC
Definition: sc_string.h:60
SC_API std::string to_string(sc_enc)
::std::istream systemc_istream
Definition: sc_string.h:74
::std::ios::fmtflags fmtflags
Definition: sc_nbdefs.h:250