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.
65 CMICmnBase::HaveErrorDescription(void) const
67 return m_strMILastErrorDescription.empty();
70 //++ ------------------------------------------------------------------------------------
71 // Details: Retrieve MI's last error condition.
74 // Return: CMIUtilString & - Text description.
78 CMICmnBase::GetErrorDescription(void) const
80 return m_strMILastErrorDescription;
83 //++ ------------------------------------------------------------------------------------
84 // Details: Set MI's error condition description. This may be accessed by clients and
85 // seen by users. Message is available to the client using the server and sent
88 // Args: vrTxt - (R) Text description.
93 CMICmnBase::SetErrorDescription(const CMIUtilString &vrTxt) const
95 m_strMILastErrorDescription = vrTxt;
98 const CMIUtilString txt(CMIUtilString::Format("Error: %s", vrTxt.c_str()));
99 CMICmnStreamStderr::Instance().Write(txt);
103 //++ ------------------------------------------------------------------------------------
104 // Details: Set MI's error condition description. This may be accessed by clients and
105 // seen by users. Message is available to the client using the server and sent
108 // Args: vrTxt - (R) Text description.
113 CMICmnBase::SetErrorDescriptionNoLog(const CMIUtilString &vrTxt) const
115 m_strMILastErrorDescription = vrTxt;
118 //++ ------------------------------------------------------------------------------------
119 // Details: Clear MI's error condition description.
126 CMICmnBase::ClrErrorDescription(void) const
128 m_strMILastErrorDescription.clear();
131 //++ ------------------------------------------------------------------------------------
132 // Details: Set MI's error condition description. This may be accessed by clients and
133 // seen by users. Message is available to the client using the server and sent
136 // Args: vFormat - (R) Format string.
137 // ... - (R) Variable number of CMIUtilString type objects.
142 CMICmnBase::SetErrorDescriptionn(const CMIUtilString vFormat, ...) const
145 va_start(args, vFormat);
146 CMIUtilString strResult = CMIUtilString::FormatValist(vFormat, args);
149 SetErrorDescription(strResult);