2010-06-09 00:52:24 +08:00
|
|
|
//===-- SBCommandReturnObject.cpp -------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "lldb/Interpreter/CommandReturnObject.h"
|
|
|
|
|
2010-06-09 15:37:52 +08:00
|
|
|
#include "lldb/API/SBCommandReturnObject.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
using namespace lldb;
|
2010-06-23 09:19:29 +08:00
|
|
|
using namespace lldb_private;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
SBCommandReturnObject::SBCommandReturnObject () :
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_ap (new CommandReturnObject ())
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SBCommandReturnObject::~SBCommandReturnObject ()
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
// m_opaque_ap will automatically delete any pointer it owns
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBCommandReturnObject::IsValid() const
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
return m_opaque_ap.get() != NULL;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const char *
|
|
|
|
SBCommandReturnObject::GetOutput ()
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_ap.get())
|
|
|
|
return m_opaque_ap->GetOutputStream().GetData();
|
2010-06-09 00:52:24 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
SBCommandReturnObject::GetError ()
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_ap.get())
|
|
|
|
return m_opaque_ap->GetErrorStream().GetData();
|
2010-06-09 00:52:24 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t
|
|
|
|
SBCommandReturnObject::GetOutputSize ()
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_ap.get())
|
|
|
|
return m_opaque_ap->GetOutputStream().GetSize();
|
2010-06-09 00:52:24 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t
|
|
|
|
SBCommandReturnObject::GetErrorSize ()
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_ap.get())
|
|
|
|
return m_opaque_ap->GetErrorStream().GetSize();
|
2010-06-09 00:52:24 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t
|
|
|
|
SBCommandReturnObject::PutOutput (FILE *fh)
|
|
|
|
{
|
|
|
|
if (fh)
|
|
|
|
{
|
|
|
|
size_t num_bytes = GetOutputSize ();
|
|
|
|
if (num_bytes)
|
|
|
|
return ::fprintf (fh, "%s", GetOutput());
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t
|
|
|
|
SBCommandReturnObject::PutError (FILE *fh)
|
|
|
|
{
|
|
|
|
if (fh)
|
|
|
|
{
|
|
|
|
size_t num_bytes = GetErrorSize ();
|
|
|
|
if (num_bytes)
|
|
|
|
return ::fprintf (fh, "%s", GetError());
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBCommandReturnObject::Clear()
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_ap.get())
|
|
|
|
m_opaque_ap->Clear();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
lldb::ReturnStatus
|
|
|
|
SBCommandReturnObject::GetStatus()
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_ap.get())
|
|
|
|
return m_opaque_ap->GetStatus();
|
2010-06-09 00:52:24 +08:00
|
|
|
return lldb::eReturnStatusInvalid;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBCommandReturnObject::Succeeded ()
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_ap.get())
|
|
|
|
return m_opaque_ap->Succeeded();
|
2010-06-09 00:52:24 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBCommandReturnObject::HasResult ()
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_ap.get())
|
|
|
|
return m_opaque_ap->HasResult();
|
2010-06-09 00:52:24 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBCommandReturnObject::AppendMessage (const char *message)
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_ap.get())
|
|
|
|
m_opaque_ap->AppendMessage (message);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
CommandReturnObject *
|
|
|
|
SBCommandReturnObject::operator ->() const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
return m_opaque_ap.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
CommandReturnObject *
|
|
|
|
SBCommandReturnObject::get() const
|
|
|
|
{
|
|
|
|
return m_opaque_ap.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
CommandReturnObject &
|
|
|
|
SBCommandReturnObject::operator *() const
|
|
|
|
{
|
|
|
|
assert(m_opaque_ap.get());
|
|
|
|
return *(m_opaque_ap.get());
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
CommandReturnObject &
|
|
|
|
SBCommandReturnObject::ref() const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
assert(m_opaque_ap.get());
|
|
|
|
return *(m_opaque_ap.get());
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2010-06-23 09:19:29 +08:00
|
|
|
SBCommandReturnObject::SetLLDBObjectPtr (CommandReturnObject *ptr)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_ap.get())
|
|
|
|
m_opaque_ap.reset (ptr);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|