CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
debug.h
1
2#pragma once
3
4#include <defines.h>
5#include <fwd.h>
6
7namespace System
8{
9
11class String;
12class Object;
13template <class T> class SmartPtr;
14template <typename T> using SharedPtr = SmartPtr<T>;
15template <class T> class Array;
16template <typename T> using ArrayPtr = SmartPtr<Array<T>>;
17namespace Collections { namespace Generic {
18 template <typename T> class List;
19}} // namespace Collections::Generic
21
22namespace Diagnostics {
23
24// Prefer to use these macroses, they don't evaluate arguments in release mode.
25#if defined(_DEBUG) || defined(DEBUG)
26 #define CODEPORTING_DEBUG_FAIL1(message) System::Diagnostics::Debug::Fail(message)
27 #define CODEPORTING_DEBUG_ASSERT1(condition) System::Diagnostics::Debug::Assert(condition)
28 #define CODEPORTING_DEBUG_ASSERT2(condition, message) System::Diagnostics::Debug::Assert(condition, message)
29 #define CODEPORTING_DEBUG_ASSERT3(condition, message, detailMessage) System::Diagnostics::Debug::Assert(condition, message, detailMessage)
30 #define CODEPORTING_DEBUG_ASSERT(condition) System::Diagnostics::Debug::Assert((bool)(condition), #condition)
31 #define CODEPORTING_DEBUG_WRITELINE1(message) System::Diagnostics::Debug::WriteLine(message)
32 #define CODEPORTING_DEBUG_WRITELINE2(message, message2) System::Diagnostics::Debug::WriteLine(message, message2)
33 #define CODEPORTING_DEBUG_WRITE1(message) System::Diagnostics::Debug::Write(message)
34 #define CODEPORTING_DEBUG_WRITEIF2(condition, message) System::Diagnostics::Debug::WriteIf(condition, message)
35 #define CODEPORTING_DEBUG_WRITELINEIF2(condition, message) System::Diagnostics::Debug::WriteLineIf(condition, message)
36 #define CODEPORTING_DEBUG_PRINT1(message) System::Diagnostics::Debug::Print(message)
37 #define CODEPORTING_DEBUG_PRINT2(format, args) System::Diagnostics::Debug::Print(format, args)
38 #define CODEPORTING_DEBUG_GET_LISTENERS() System::Diagnostics::Debug::get_Listeners()
39#else
40 #define CODEPORTING_DEBUG_FAIL1(message) do { (void)sizeof(message);} while (0)
41 #define CODEPORTING_DEBUG_ASSERT1(condition) do { (void)sizeof(condition);} while (0)
42 #define CODEPORTING_DEBUG_ASSERT2(condition, message) do { (void)sizeof(condition); (void)sizeof(message);} while (0)
43 #define CODEPORTING_DEBUG_ASSERT3(condition, message, detailMessage) do { (void)sizeof(condition); (void)sizeof(message); (void)sizeof(detailMessage);} while (0)
44 #define CODEPORTING_DEBUG_ASSERT(condition) do { (void)sizeof(condition); } while (0)
45 #define CODEPORTING_DEBUG_WRITELINE1(message) do { (void)sizeof(message);} while (0)
46 #define CODEPORTING_DEBUG_WRITELINE2(message, message2) do { (void)sizeof(message); (void)sizeof(message2);} while (0)
47 #define CODEPORTING_DEBUG_WRITE1(message) do { (void)sizeof(message);} while (0)
48 #define CODEPORTING_DEBUG_WRITEIF2(condition, message) do { (void)sizeof(condition); (void)sizeof(message);} while (0)
49 #define CODEPORTING_DEBUG_WRITELINEIF2(condition, message) do { (void)sizeof(condition); (void)sizeof(message);} while (0)
50 #define CODEPORTING_DEBUG_PRINT1(message) do { (void)sizeof(message);} while (0)
51 #define CODEPORTING_DEBUG_PRINT2(format, args) do { (void)sizeof(format); (void)sizeof(args);} while (0)
52 #define CODEPORTING_DEBUG_GET_LISTENERS() System::Diagnostics::Debug::get_Listeners()
53#endif
54
55class TraceListener;
56
57
62struct Debug
63{
66 static ASPOSECPP_SHARED_API void Fail(const String& message);
69 static ASPOSECPP_SHARED_API void Assert(bool condition);
73 static ASPOSECPP_SHARED_API void Assert(bool condition, const String& message);
77 static ASPOSECPP_SHARED_API void Assert(bool condition, const char* message);
82 static ASPOSECPP_SHARED_API void Assert(bool condition, const String& message, const String& detailMessage);
85 static ASPOSECPP_SHARED_API void WriteLine(const String& message);
89 static ASPOSECPP_SHARED_API void WriteLine(const String& message, const String& message2);
92 static ASPOSECPP_SHARED_API void WriteLine(const char_t* message);
95 static ASPOSECPP_SHARED_API void WriteLine(const SharedPtr<Object>& obj);
98 static ASPOSECPP_SHARED_API void Write(const String& message);
101 static ASPOSECPP_SHARED_API void Write(const char_t* message);
105 static ASPOSECPP_SHARED_API void WriteIf(bool condition, const System::String& message);
109 static ASPOSECPP_SHARED_API void WriteLineIf(bool condition, const System::String& message);
112 static ASPOSECPP_SHARED_API void Print(const String& message);
116 static ASPOSECPP_SHARED_API void Print(const String& format, const System::ArrayPtr<SharedPtr<System::Object>>& args);
117
121};
122
123}} // namespace System::Diagnostics
Interface to react to debug and trace infofmation. Objects of this class should only be allocated usi...
Definition: trace_listener.h:15
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
String class used across the library. Is a substitute for C# System.String when translating code....
Definition: string.h:122
class ASPOSECPP_SHARED_CLASS List
Definition: ienumerable.h:18
Definition: db_command.h:9
SmartPtr< Array< T > > ArrayPtr
Alias for 'pointer to array' type.
Definition: smart_ptr.h:1776
SmartPtr< T > SharedPtr
Alias for smart pointer widely used in the library.
Definition: smart_ptr.h:1779
class ASPOSECPP_SHARED_CLASS Array
Definition: smart_ptr.h:22
Collection of debug methods allowing it sending debug information to registered listeners....
Definition: debug.h:63
static void Assert(bool condition, const char *message)
Assert condition and send information on failure.
static void Write(const char_t *message)
Writes string to debug interface.
static void WriteIf(bool condition, const System::String &message)
Writes string to debug interface if a condition is true.
static void Print(const String &format, const System::ArrayPtr< SharedPtr< System::Object > > &args)
Print message to debug interface.
static void WriteLine(const String &message)
Writes line to debug interface.
static void Assert(bool condition, const String &message)
Assert condition and send information on failure.
static void Assert(bool condition)
Assert condition and send information on failure.
static void Print(const String &message)
Print message to debug interface.
static void Write(const String &message)
Writes string to debug interface.
static void Fail(const String &message)
Send fail message.
static void WriteLine(const String &message, const String &message2)
Writes line to debug interface.
static System::SharedPtr< System::Collections::Generic::List< System::SharedPtr< TraceListener > > > get_Listeners()
Accesses static list of listeners.
static void WriteLine(const SharedPtr< Object > &obj)
Writes line to debug interface.
static void WriteLineIf(bool condition, const System::String &message)
Writes line to debug interface if a condition is true.
static void Assert(bool condition, const String &message, const String &detailMessage)
Assert condition and send information on failure.
static void WriteLine(const char_t *message)
Writes line to debug interface.