aboutsummaryrefslogtreecommitdiffstats
path: root/tools/lldb-mi/MIUtilMapIdToVariant.h
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-01-02 19:26:05 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-01-02 19:26:05 +0000
commit14f1b3e8826ce43b978db93a62d1166055db5394 (patch)
tree0a00ad8d3498783fe0193f3b656bca17c4c8697d /tools/lldb-mi/MIUtilMapIdToVariant.h
parent4ee8c119c71a06dcad1e0fecc8c675e480e59337 (diff)
downloadsrc-14f1b3e8826ce43b978db93a62d1166055db5394.tar.gz
src-14f1b3e8826ce43b978db93a62d1166055db5394.zip
Vendor import of lldb trunk r290819:vendor/lldb/lldb-trunk-r290819
Notes
Notes: svn path=/vendor/lldb/dist/; revision=311128 svn path=/vendor/lldb/lldb-trunk-r290819/; revision=311129; tag=vendor/lldb/lldb-trunk-r290819
Diffstat (limited to 'tools/lldb-mi/MIUtilMapIdToVariant.h')
-rw-r--r--tools/lldb-mi/MIUtilMapIdToVariant.h163
1 files changed, 81 insertions, 82 deletions
diff --git a/tools/lldb-mi/MIUtilMapIdToVariant.h b/tools/lldb-mi/MIUtilMapIdToVariant.h
index 1a164907dd06..a56477c4dba9 100644
--- a/tools/lldb-mi/MIUtilMapIdToVariant.h
+++ b/tools/lldb-mi/MIUtilMapIdToVariant.h
@@ -18,45 +18,49 @@
#include "MIUtilString.h"
#include "MIUtilVariant.h"
-//++ ============================================================================
+//++
+//============================================================================
// Details: MI common code utility class. Map type container that hold general
// object types (by being a variant wrapper)
// objects by ID.
//--
-class CMIUtilMapIdToVariant : public CMICmnBase
-{
- // Methods:
- public:
- /* ctor */ CMIUtilMapIdToVariant();
-
- template <typename T> bool Add(const CMIUtilString &vId, const T &vData);
- void Clear();
- template <typename T> bool Get(const CMIUtilString &vId, T &vrwData, bool &vrwbFound) const;
- bool HaveAlready(const CMIUtilString &vId) const;
- bool IsEmpty() const;
- bool Remove(const CMIUtilString &vId);
-
- // Overridden:
- public:
- // From CMICmnBase
- /* dtor */ ~CMIUtilMapIdToVariant() override;
-
- // Typedefs:
- private:
- typedef std::map<CMIUtilString, CMIUtilVariant> MapKeyToVariantValue_t;
- typedef std::pair<CMIUtilString, CMIUtilVariant> MapPairKeyToVariantValue_t;
-
- // Methods:
- private:
- bool IsValid(const CMIUtilString &vId) const;
-
- // Attributes:
- MapKeyToVariantValue_t m_mapKeyToVariantValue;
+class CMIUtilMapIdToVariant : public CMICmnBase {
+ // Methods:
+public:
+ /* ctor */ CMIUtilMapIdToVariant();
+
+ template <typename T> bool Add(const CMIUtilString &vId, const T &vData);
+ void Clear();
+ template <typename T>
+ bool Get(const CMIUtilString &vId, T &vrwData, bool &vrwbFound) const;
+ bool HaveAlready(const CMIUtilString &vId) const;
+ bool IsEmpty() const;
+ bool Remove(const CMIUtilString &vId);
+
+ // Overridden:
+public:
+ // From CMICmnBase
+ /* dtor */ ~CMIUtilMapIdToVariant() override;
+
+ // Typedefs:
+private:
+ typedef std::map<CMIUtilString, CMIUtilVariant> MapKeyToVariantValue_t;
+ typedef std::pair<CMIUtilString, CMIUtilVariant> MapPairKeyToVariantValue_t;
+
+ // Methods:
+private:
+ bool IsValid(const CMIUtilString &vId) const;
+
+ // Attributes:
+ MapKeyToVariantValue_t m_mapKeyToVariantValue;
};
-//++ ------------------------------------------------------------------------------------
-// Details: Add to *this container a data object of general type identified by an ID.
-// If the data with that ID already exists in the container it is replace with
+//++
+//------------------------------------------------------------------------------------
+// Details: Add to *this container a data object of general type identified by
+// an ID.
+// If the data with that ID already exists in the container it is
+// replace with
// the new data specified.
// Type: Method.
// Args: T - The data object's variable type.
@@ -67,29 +71,28 @@ class CMIUtilMapIdToVariant : public CMICmnBase
// Throws: None.
//--
template <typename T>
-bool
-CMIUtilMapIdToVariant::Add(const CMIUtilString &vId, const T &vData)
-{
- if (!IsValid(vId))
- {
- SetErrorDescription(CMIUtilString::Format(MIRSRC(IDS_VARIANT_ERR_MAP_KEY_INVALID), vId.c_str()));
- return MIstatus::failure;
- }
-
- const bool bOk = HaveAlready(vId) ? Remove(vId) : MIstatus::success;
- if (bOk)
- {
- CMIUtilVariant data;
- data.Set<T>(vData);
- MapPairKeyToVariantValue_t pr(vId, data);
- m_mapKeyToVariantValue.insert(pr);
- }
-
- return bOk;
+bool CMIUtilMapIdToVariant::Add(const CMIUtilString &vId, const T &vData) {
+ if (!IsValid(vId)) {
+ SetErrorDescription(CMIUtilString::Format(
+ MIRSRC(IDS_VARIANT_ERR_MAP_KEY_INVALID), vId.c_str()));
+ return MIstatus::failure;
+ }
+
+ const bool bOk = HaveAlready(vId) ? Remove(vId) : MIstatus::success;
+ if (bOk) {
+ CMIUtilVariant data;
+ data.Set<T>(vData);
+ MapPairKeyToVariantValue_t pr(vId, data);
+ m_mapKeyToVariantValue.insert(pr);
+ }
+
+ return bOk;
}
-//++ ------------------------------------------------------------------------------------
-// Details: Retrieve a data object from *this container identified by the specified ID.
+//++
+//------------------------------------------------------------------------------------
+// Details: Retrieve a data object from *this container identified by the
+// specified ID.
// Type: Method.
// Args: T - The data object's variable type.
// vId - (R) Unique ID i.e. GUID.
@@ -100,34 +103,30 @@ CMIUtilMapIdToVariant::Add(const CMIUtilString &vId, const T &vData)
// Throws: None.
//--
template <typename T>
-bool
-CMIUtilMapIdToVariant::Get(const CMIUtilString &vId, T &vrwData, bool &vrwbFound) const
-{
- vrwbFound = false;
-
- if (!IsValid(vId))
- {
- SetErrorDescription(CMIUtilString::Format(MIRSRC(IDS_VARIANT_ERR_MAP_KEY_INVALID), vId.c_str()));
- return MIstatus::failure;
- }
-
- const MapKeyToVariantValue_t::const_iterator it = m_mapKeyToVariantValue.find(vId);
- if (it != m_mapKeyToVariantValue.end())
- {
- const CMIUtilVariant &rData = (*it).second;
- const T *pDataObj = rData.Get<T>();
- if (pDataObj != nullptr)
- {
- vrwbFound = true;
- vrwData = *pDataObj;
- return MIstatus::success;
- }
- else
- {
- SetErrorDescription(MIRSRC(IDS_VARIANT_ERR_USED_BASECLASS));
- return MIstatus::failure;
- }
+bool CMIUtilMapIdToVariant::Get(const CMIUtilString &vId, T &vrwData,
+ bool &vrwbFound) const {
+ vrwbFound = false;
+
+ if (!IsValid(vId)) {
+ SetErrorDescription(CMIUtilString::Format(
+ MIRSRC(IDS_VARIANT_ERR_MAP_KEY_INVALID), vId.c_str()));
+ return MIstatus::failure;
+ }
+
+ const MapKeyToVariantValue_t::const_iterator it =
+ m_mapKeyToVariantValue.find(vId);
+ if (it != m_mapKeyToVariantValue.end()) {
+ const CMIUtilVariant &rData = (*it).second;
+ const T *pDataObj = rData.Get<T>();
+ if (pDataObj != nullptr) {
+ vrwbFound = true;
+ vrwData = *pDataObj;
+ return MIstatus::success;
+ } else {
+ SetErrorDescription(MIRSRC(IDS_VARIANT_ERR_USED_BASECLASS));
+ return MIstatus::failure;
}
+ }
- return MIstatus::success;
+ return MIstatus::success;
}