2014-06-25 00:35:50 +08:00
|
|
|
//===-- MIUtilMapIdToVariant.cpp --------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
//++
|
2014-11-18 02:06:21 +08:00
|
|
|
// File: MIUtilMapIdToVariant.cpp
|
2014-06-25 00:35:50 +08:00
|
|
|
//
|
2014-11-18 02:06:21 +08:00
|
|
|
// Overview: CMIUtilMapIdToVariant implementation.
|
2014-06-25 00:35:50 +08:00
|
|
|
//
|
2014-11-18 02:06:21 +08:00
|
|
|
// Environment: Compilers: Visual C++ 12.
|
|
|
|
// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
|
|
|
|
// Libraries: See MIReadmetxt.
|
2014-06-25 00:35:50 +08:00
|
|
|
//
|
2014-11-18 02:06:21 +08:00
|
|
|
// Copyright: None.
|
2014-06-25 00:35:50 +08:00
|
|
|
//--
|
|
|
|
|
|
|
|
// In-house headers:
|
|
|
|
#include "MIUtilMapIdToVariant.h"
|
|
|
|
|
|
|
|
//++ ------------------------------------------------------------------------------------
|
2014-11-18 02:06:21 +08:00
|
|
|
// Details: CMIUtilMapIdToVariant constructor.
|
|
|
|
// Type: Method.
|
|
|
|
// Args: None.
|
|
|
|
// Return: None.
|
|
|
|
// Throws: None.
|
2014-06-25 00:35:50 +08:00
|
|
|
//--
|
2014-11-18 02:06:21 +08:00
|
|
|
CMIUtilMapIdToVariant::CMIUtilMapIdToVariant(void)
|
2014-06-25 00:35:50 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//++ ------------------------------------------------------------------------------------
|
2014-11-18 02:06:21 +08:00
|
|
|
// Details: CMIUtilMapIdToVariant destructor.
|
|
|
|
// Type: Method.
|
|
|
|
// Args: None.
|
|
|
|
// Return: None.
|
|
|
|
// Throws: None.
|
2014-06-25 00:35:50 +08:00
|
|
|
//--
|
2014-11-18 02:06:21 +08:00
|
|
|
CMIUtilMapIdToVariant::~CMIUtilMapIdToVariant(void)
|
2014-06-25 00:35:50 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//++ ------------------------------------------------------------------------------------
|
2014-11-18 02:06:21 +08:00
|
|
|
// Details: Remove at the data from *this container.
|
|
|
|
// Type: Method.
|
|
|
|
// Args: None.
|
|
|
|
// Return: None.
|
|
|
|
// Throws: None.
|
2014-06-25 00:35:50 +08:00
|
|
|
//--
|
2014-11-18 02:06:21 +08:00
|
|
|
void
|
|
|
|
CMIUtilMapIdToVariant::Clear(void)
|
2014-06-25 00:35:50 +08:00
|
|
|
{
|
2014-11-18 02:06:21 +08:00
|
|
|
m_mapKeyToVariantValue.clear();
|
2014-06-25 00:35:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//++ ------------------------------------------------------------------------------------
|
2014-11-18 02:06:21 +08:00
|
|
|
// Details: Check an ID is present already in *this container.
|
|
|
|
// Type: Method.
|
|
|
|
// Args: vId - (R) Unique ID i.e. GUID.
|
|
|
|
// Return: True - registered.
|
|
|
|
// False - not found.
|
|
|
|
// Throws: None.
|
2014-06-25 00:35:50 +08:00
|
|
|
//--
|
2014-11-18 02:06:21 +08:00
|
|
|
bool
|
|
|
|
CMIUtilMapIdToVariant::HaveAlready(const CMIUtilString &vId) const
|
2014-06-25 00:35:50 +08:00
|
|
|
{
|
2014-11-18 02:06:21 +08:00
|
|
|
const MapKeyToVariantValue_t::const_iterator it = m_mapKeyToVariantValue.find(vId);
|
|
|
|
if (it != m_mapKeyToVariantValue.end())
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
2014-06-25 00:35:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//++ ------------------------------------------------------------------------------------
|
2014-11-18 02:06:21 +08:00
|
|
|
// Details: Determine if *this container is currently holding any data.
|
|
|
|
// Type: Method.
|
|
|
|
// Args: None.
|
|
|
|
// Return: bool - True - Yes empty, false - one or more data object present.
|
|
|
|
// Throws: None.
|
2014-06-25 00:35:50 +08:00
|
|
|
//--
|
2014-11-18 02:06:21 +08:00
|
|
|
bool
|
|
|
|
CMIUtilMapIdToVariant::IsEmpty(void) const
|
2014-06-25 00:35:50 +08:00
|
|
|
{
|
2014-11-18 02:06:21 +08:00
|
|
|
return m_mapKeyToVariantValue.empty();
|
2014-06-25 00:35:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//++ ------------------------------------------------------------------------------------
|
2014-11-18 02:06:21 +08:00
|
|
|
// Details: Check the ID is valid to be registered.
|
|
|
|
// Type: Method.
|
|
|
|
// Args: vId - (R) Unique ID i.e. GUID.
|
|
|
|
// Return: True - valid.
|
|
|
|
// False - not valid.
|
|
|
|
// Throws: None.
|
2014-06-25 00:35:50 +08:00
|
|
|
//--
|
2014-11-18 02:06:21 +08:00
|
|
|
bool
|
|
|
|
CMIUtilMapIdToVariant::IsValid(const CMIUtilString &vId) const
|
2014-06-25 00:35:50 +08:00
|
|
|
{
|
2014-11-18 02:06:21 +08:00
|
|
|
bool bValid = true;
|
|
|
|
|
|
|
|
if (vId.empty())
|
|
|
|
bValid = false;
|
2014-06-25 00:35:50 +08:00
|
|
|
|
2014-11-18 02:06:21 +08:00
|
|
|
return bValid;
|
2014-06-25 00:35:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//++ ------------------------------------------------------------------------------------
|
2014-11-18 02:06:21 +08:00
|
|
|
// Details: Remove from *this contain a data object specified by ID. The data object
|
|
|
|
// when removed also calls its destructor should it have one.
|
|
|
|
// Type: Method.
|
|
|
|
// Args: vId - (R) Unique ID i.e. GUID.
|
|
|
|
// Return: MIstatus::success - Functional succeeded.
|
|
|
|
// MIstatus::failure - Functional failed.
|
|
|
|
// Throws: None.
|
2014-06-25 00:35:50 +08:00
|
|
|
//--
|
2014-11-18 02:06:21 +08:00
|
|
|
bool
|
|
|
|
CMIUtilMapIdToVariant::Remove(const CMIUtilString &vId)
|
2014-06-25 00:35:50 +08:00
|
|
|
{
|
2014-11-18 02:06:21 +08:00
|
|
|
const MapKeyToVariantValue_t::const_iterator it = m_mapKeyToVariantValue.find(vId);
|
|
|
|
if (it != m_mapKeyToVariantValue.end())
|
|
|
|
{
|
|
|
|
m_mapKeyToVariantValue.erase(it);
|
|
|
|
}
|
2014-06-25 00:35:50 +08:00
|
|
|
|
2014-11-18 02:06:21 +08:00
|
|
|
return MIstatus::success;
|
2014-06-25 00:35:50 +08:00
|
|
|
}
|