llvm-project/lldb/tools/lldb-mi/MIUtilSetID.cpp
Deepak Panickal 6f9c468102 Initial commit of LLDB Machine Interface Frontend.
- Tested with Eclipse, likely to work with other GDB/MI compatible GUIs.
- Some but not all MI commands have been implemented. See MIReadme.txt for more info.
- Written from scratch, no GPL code, based on LLDB Public API.
- Built for Linux, Windows and OSX. Tested on Linux and Windows.
- GDB/MI Command Reference, https://sourceware.org/gdb/onlinedocs/gdb/GDB_002fMI.html

llvm-svn: 208972
2014-05-16 10:51:01 +00:00

127 lines
3.0 KiB
C++

//===-- MIUtilSetID.cpp -----------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//++
// File: MIUtilSetID.cpp
//
// Overview: CMIUtilSetID interface.
//
// Environment: Compilers: Visual C++ 12.
// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
// Libraries: See MIReadmetxt.
//
// Copyright: None.
//--
// In-house headers:
#include "MIUtilSetID.h"
//++ ------------------------------------------------------------------------------------
// Details: CMIUtilSetID constructor.
// Type: Method.
// Args: None.
// Return: None.
// Throws: None.
//--
CMIUtilSetID::CMIUtilSetID( void )
{
}
//++ ------------------------------------------------------------------------------------
// Details: CMIUtilSetID destructor.
// Type: Method.
// Args: None.
// Return: None.
// Throws: None.
//--
CMIUtilSetID::~CMIUtilSetID( void )
{
}
//++ ------------------------------------------------------------------------------------
// Details: Register an ID.
// Type: Method.
// Args: vId - (R) Unique ID i.e. GUID.
// Return: MIstatus::success - Functional succeeded.
// MIstatus::failure - Functional failed.
// Throws: None.
//--
bool CMIUtilSetID::Register( const CMIUtilString & vId )
{
if( !IsValid( vId ) )
{
SetErrorDescription( CMIUtilString::Format( "ID '%s' invalid", vId.c_str() ) );
return MIstatus::failure;
}
if( HaveAlready( vId ) )
return MIstatus::success;
insert( vId );
return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
// Details: Unregister an ID.
// Type: Method.
// Args: vId - (R) Unique ID i.e. GUID.
// Return: MIstatus::success - Functional succeeded.
// MIstatus::failure - Functional failed.
// Throws: None.
//--
bool CMIUtilSetID::Unregister( const CMIUtilString & vId )
{
if( !IsValid( vId ) )
{
SetErrorDescription( CMIUtilString::Format( "ID '%s' invalid", vId.c_str() ) );
return MIstatus::failure;
}
erase( vId );
return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
// Details: Check an ID is already registered.
// Type: Method.
// Args: vId - (R) Unique ID i.e. GUID.
// Return: True - registered.
// False - not found.
// Throws: None.
//--
bool CMIUtilSetID::HaveAlready( const CMIUtilString & vId ) const
{
const_iterator it = find( vId );
if( it != end() )
return true;
return false;
}
//++ ------------------------------------------------------------------------------------
// 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.
//--
bool CMIUtilSetID::IsValid( const CMIUtilString & vId ) const
{
bool bValid = true;
if( vId.empty() )
bValid = false;
return bValid;
}