BeConsole.h
Go to the documentation of this file.
1 /*--------------------------------------------------------------------------------------+
2 |
3 | Supplied under applicable software license agreement.
4 |
5 | Copyright (c) 2018 Bentley Systems, Incorporated. All rights reserved.
6 |
7 +---------------------------------------------------------------------------------------*/
8 #pragma once
9 
11 
12 #include <stdio.h>
13 
14 #include "Bentley.h"
15 #include "NonCopyableClass.h"
16 
18 
21 
22 /*=================================================================================**/
26 struct BeConsole : public NonCopyableClass
27  {
28 public:
29  BENTLEYDLL_EXPORT static FILE* GetStdin ();
30  BENTLEYDLL_EXPORT static FILE* GetStdout ();
31  BENTLEYDLL_EXPORT static FILE* GetStderr ();
32 
33  BENTLEYDLL_EXPORT static int Printf (CharCP, ...);
34  BENTLEYDLL_EXPORT static int VPrintf (CharCP, va_list);
35 
36  BENTLEYDLL_EXPORT static int FPrintf (FILE*, CharCP, ...);
37  BENTLEYDLL_EXPORT static int VFPrintf (FILE*, CharCP, va_list);
38 
39  BENTLEYDLL_EXPORT static int FPuts (CharCP, FILE *);
40 
41  BENTLEYDLL_EXPORT static int WPrintf (WCharCP, ...);
42  BENTLEYDLL_EXPORT static int VWPrintf (WCharCP, va_list);
43 
44  BENTLEYDLL_EXPORT static int FWPrintf (FILE *, WCharCP, ...);
45  BENTLEYDLL_EXPORT static int VFWPrintf (FILE *, WCharCP, va_list);
46 
47  BENTLEYDLL_EXPORT static int FPutws (WCharCP, FILE *);
48 
49  BENTLEYDLL_EXPORT static int FFlush (FILE *);
50  BENTLEYDLL_EXPORT static int FClose (FILE *);
51  BENTLEYDLL_EXPORT static size_t FWrite (const void *, size_t, size_t, FILE *);
52 
53  BENTLEYDLL_EXPORT static int FGetc (FILE *);
54 
55  };
56 
58 
60 
61 # if !defined (NO_IODEFS)
62 /*---------------------------------------------------+
63 | Redefine the printf style output functions. |
64 | Include stdio.h here so it won't interfere later. |
65 | The reason we do this is to cause printf's and |
66 | fprintfs and fwrites to stdout and stderr to be |
67 | redirected to MicroStation's console window so |
68 | they will be visible for debugging purposes. If |
69 | you don't want that behavior, #define NO_IODEFS |
70 | before including basedefs.h. In that case, your |
71 | output to stdout and stderr is not displayed. |
72 +---------------------------------------------------*/
73 #include <cstdio>
74 
75 # undef stdout
76 # define stdout BeConsole::GetStdout()
77 
78 # undef stdin
79 # define stdin BeConsole::GetStdin()
80 
81 # undef stderr
82 # define stderr BeConsole::GetStderr()
83 
84 # undef printf
85 # define printf BeConsole::Printf
86 
87 # undef wprintf
88 # define wprintf BeConsole::WPrintf
89 
90 # undef fflush
91 # define fflush BeConsole::FFlush
92 
93 # undef fwrite
94 # define fwrite BeConsole::FWrite
95 
96 # undef fprintf
97 # define fprintf BeConsole::FPrintf
98 
99 # undef fwprintf
100 # define fwprintf BeConsole::FWPrintf
101 
102 # undef fgetc
103 # define fgetc BeConsole::FGetc
104 
105 # endif
#define BENTLEYDLL_EXPORT
Definition: Bentley.h:249
wchar_t const * WCharCP
Definition: Bentley.h:224
#define BEGIN_BENTLEY_NAMESPACE
Definition: Bentley.r.h:24
Declares the NonCopyableClass.
Defines typedefs and constants that can be used across other namespaces. All Bentley-authored C++ sou...
Base class to make a class non-copyable.
Definition: NonCopyableClass.h:23
char const * CharCP
Definition: Bentley.h:226
#define END_BENTLEY_NAMESPACE
Definition: Bentley.r.h:25
BeConsold Class provides a collection of functions for the Console.
Definition: BeConsole.h:26

Copyright © 2017 Bentley Systems, Incorporated. All rights reserved.