1 //===-- MICmnBase.cpp -------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 // File: MICmnBase.cpp
13 // Overview: CMICmnBase implementation.
15 // Environment: Compilers: Visual C++ 12.
16 // gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
17 // Libraries: See MIReadmetxt.
22 // Third party headers
23 #include <stdarg.h> // va_list, va_start, var_end
26 #include "MICmnBase.h"
28 #include "MICmnStreamStderr.h"
30 //++ ------------------------------------------------------------------------------------
31 // Details: CMICmnBase constructor.
37 CMICmnBase::CMICmnBase( void )
38 : m_strMILastErrorDescription( CMIUtilString() )
39 , m_bInitialized( false )
40 , m_pLog( &CMICmnLog::Instance() )
41 , m_clientUsageRefCnt( 0 )
45 //++ ------------------------------------------------------------------------------------
46 // Details: CMICmnBase destructor.
47 // Type: Overrideable.
52 CMICmnBase::~CMICmnBase( void )
57 //++ ------------------------------------------------------------------------------------
58 // Details: Retrieve whether *this object has an error description set.
61 // Return: bool - True = Yes already defined, false = empty discription.
64 bool CMICmnBase::HaveErrorDescription( void ) const
66 return m_strMILastErrorDescription.empty();
69 //++ ------------------------------------------------------------------------------------
70 // Details: Retrieve MI's last error condition.
73 // Return: CMIUtilString & - Text description.
76 const CMIUtilString & CMICmnBase::GetErrorDescription( void ) const
78 return m_strMILastErrorDescription;
81 //++ ------------------------------------------------------------------------------------
82 // Details: Set MI's error condition description. This may be accessed by clients and
83 // seen by users. Message is available to the client using the server and sent
86 // Args: vrTxt - (R) Text description.
90 void CMICmnBase::SetErrorDescription( const CMIUtilString & vrTxt ) const
92 m_strMILastErrorDescription = vrTxt;
95 const CMIUtilString txt( CMIUtilString::Format( "Error: %s", vrTxt.c_str() ) );
96 CMICmnStreamStderr::Instance().Write( txt );
100 //++ ------------------------------------------------------------------------------------
101 // Details: Set MI's error condition description. This may be accessed by clients and
102 // seen by users. Message is available to the client using the server and sent
105 // Args: vrTxt - (R) Text description.
109 void CMICmnBase::SetErrorDescriptionNoLog( const CMIUtilString & vrTxt ) const
111 m_strMILastErrorDescription = vrTxt;
114 //++ ------------------------------------------------------------------------------------
115 // Details: Clear MI's error condition description.
121 void CMICmnBase::ClrErrorDescription( void ) const
123 m_strMILastErrorDescription.clear();
126 //++ ------------------------------------------------------------------------------------
127 // Details: Set MI's error condition description. This may be accessed by clients and
128 // seen by users. Message is available to the client using the server and sent
131 // Args: vrFormat - (R) Format string.
132 // ... - (R) Variable number of CMIUtilString type objects.
136 void CMICmnBase::SetErrorDescriptionn( const CMIUtilString & vrFormat, ... ) const
139 va_start( args, vrFormat );
140 CMIUtilString strResult = CMIUtilString::FormatValist( vrFormat, args );
143 SetErrorDescription( strResult );