Index: include/lldb/API/SBArgs.h =================================================================== --- /dev/null +++ include/lldb/API/SBArgs.h @@ -0,0 +1,48 @@ +//===-- SBArgs.h ------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBArgs_h_ +#define LLDB_SBArgs_h_ + +#include "lldb/API/SBDefines.h" +#include + +namespace lldb +{ + +class LLDB_API SBArgs +{ + public: + SBArgs(); + + SBArgs(const lldb::SBArgs &rhs); + + ~SBArgs(); + + lldb::SBArgs &operator=(const lldb::SBArgs &rhs); + + void SetCommandString(const std::string &command); + + std::string GetCommandString() const; + + std::string GetQuotedCommandString() const; + + size_t GetArgumentCount() const; + + std::string GetArgumentAtIndex(size_t idx) const; + + void AppendArgument(const std::string &argument); + + private: + std::shared_ptr m_opaque_ptr; +}; + +} // namespace lldb + +#endif // LLDB_SBBlock_h_ Index: include/lldb/API/SBDefines.h =================================================================== --- include/lldb/API/SBDefines.h +++ include/lldb/API/SBDefines.h @@ -29,6 +29,7 @@ namespace lldb { class LLDB_API SBAddress; +class LLDB_API SBArgs; class LLDB_API SBBlock; class LLDB_API SBBreakpoint; class LLDB_API SBBreakpointLocation; Index: scripts/Python/interface/SBArgs.i =================================================================== --- /dev/null +++ scripts/Python/interface/SBArgs.i @@ -0,0 +1,45 @@ +//===-- SWIG Interface for SBArgs -------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +% include "std_string.i" + + namespace lldb +{ + + % feature("docstring", "Represents the LLDB command string parser / tokenizer") SBArgs; + + class SBArgs + { + public: + SBArgs(); + + SBArgs(const lldb::SBArgs &rhs); + + ~SBArgs(); + + % feature("docstring", "Sets and tokenizes the command string") SetCommandString; + void SetCommandString(const ::std::string &command); + + % feature("docstring", "Gets the untokenized command string") GetCommandString; + ::std::string GetCommandString() const; + + % feature("docstring", "Gets the untokenized command string with all arguments quoted") GetQuotedCommandString; + ::std::string GetQuotedCommandString() const; + + % feature("docstring", "Gets the number of arguments tokenized") GetArgumentCount; + size_t GetArgumentCount() const; + + % feature("docstring", "Gets the argument at the specified index") GetArgumentAtIndex; + ::std::string GetArgumentAtIndex(size_t idx) const; + + % feature("docstring", "Appends a single argument to the end of the argument list") AppendArgument; + void AppendArgument(const ::std::string &argument); + }; + +} // namespace lldb \ No newline at end of file Index: scripts/lldb.swig =================================================================== --- scripts/lldb.swig +++ scripts/lldb.swig @@ -53,6 +53,7 @@ %{ #include "lldb/lldb-public.h" #include "lldb/API/SBAddress.h" +#include "lldb/API/SBArgs.h" #include "lldb/API/SBAttachInfo.h" #include "lldb/API/SBBlock.h" #include "lldb/API/SBBreakpoint.h" @@ -130,6 +131,7 @@ /* Python interface files with docstrings. */ %include "./Python/interface/SBAddress.i" +%include "./Python/interface/SBArgs.i" %include "./Python/interface/SBAttachInfo.i" %include "./Python/interface/SBBlock.i" %include "./Python/interface/SBBreakpoint.i" Index: source/API/CMakeLists.txt =================================================================== --- source/API/CMakeLists.txt +++ source/API/CMakeLists.txt @@ -21,6 +21,7 @@ # So lldbAPI must be an OBJECT library. add_lldb_library(lldbAPI OBJECT SBAddress.cpp + SBArgs.cpp SBAttachInfo.cpp SBBlock.cpp SBBreakpoint.cpp Index: source/API/SBArgs.cpp =================================================================== --- /dev/null +++ source/API/SBArgs.cpp @@ -0,0 +1,74 @@ +//===-- SBAddress.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/API/SBArgs.h" +#include "lldb/Interpreter/Args.h" + +using namespace lldb; +using namespace lldb_private; + +SBArgs::SBArgs() + : m_opaque_ptr(new Args()) +{ +} + +SBArgs::SBArgs(const SBArgs &rhs) + : m_opaque_ptr(rhs.m_opaque_ptr) +{ +} + +SBArgs::~SBArgs() +{ +} + +SBArgs &SBArgs::operator=(const lldb::SBArgs &rhs) +{ + m_opaque_ptr = rhs.m_opaque_ptr; + return *this; +} + +void +SBArgs::SetCommandString(const std::string &command) +{ + m_opaque_ptr->SetCommandString(command); +} + +std::string +SBArgs::GetCommandString() const +{ + std::string result; + m_opaque_ptr->GetCommandString(result); + return result; +} + +std::string +SBArgs::GetQuotedCommandString() const +{ + std::string result; + m_opaque_ptr->GetQuotedCommandString(result); + return result; +} + +size_t +SBArgs::GetArgumentCount() const +{ + return m_opaque_ptr->GetArgumentCount(); +} + +std::string +SBArgs::GetArgumentAtIndex(size_t idx) const +{ + return m_opaque_ptr->GetArgumentAtIndex(idx); +} + +void +SBArgs::AppendArgument(const std::string &argument) +{ + m_opaque_ptr->AppendArgument(argument.c_str()); +}