aboutsummaryrefslogtreecommitdiff
path: root/lldb/tools/lldb-mi/MICmdArgContext.cpp
diff options
context:
space:
mode:
authorKate Stone <katherine.stone@apple.com>2016-09-06 20:57:50 +0000
committerKate Stone <katherine.stone@apple.com>2016-09-06 20:57:50 +0000
commitb9c1b51e45b845debb76d8658edabca70ca56079 (patch)
treedfcb5a13ef2b014202340f47036da383eaee74aa /lldb/tools/lldb-mi/MICmdArgContext.cpp
parentd5aa73376966339caad04013510626ec2e42c760 (diff)
downloadllvm-b9c1b51e45b845debb76d8658edabca70ca56079.zip
llvm-b9c1b51e45b845debb76d8658edabca70ca56079.tar.gz
llvm-b9c1b51e45b845debb76d8658edabca70ca56079.tar.bz2
*** This commit represents a complete reformatting of the LLDB source code
*** to conform to clang-format’s LLVM style. This kind of mass change has *** two obvious implications: Firstly, merging this particular commit into a downstream fork may be a huge effort. Alternatively, it may be worth merging all changes up to this commit, performing the same reformatting operation locally, and then discarding the merge for this particular commit. The commands used to accomplish this reformatting were as follows (with current working directory as the root of the repository): find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} + find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ; The version of clang-format used was 3.9.0, and autopep8 was 1.2.4. Secondly, “blame” style tools will generally point to this commit instead of a meaningful prior commit. There are alternatives available that will attempt to look through this change and find the appropriate prior commit. YMMV. llvm-svn: 280751
Diffstat (limited to 'lldb/tools/lldb-mi/MICmdArgContext.cpp')
-rw-r--r--lldb/tools/lldb-mi/MICmdArgContext.cpp281
1 files changed, 134 insertions, 147 deletions
diff --git a/lldb/tools/lldb-mi/MICmdArgContext.cpp b/lldb/tools/lldb-mi/MICmdArgContext.cpp
index 8ce5bfb..57f682b 100644
--- a/lldb/tools/lldb-mi/MICmdArgContext.cpp
+++ b/lldb/tools/lldb-mi/MICmdArgContext.cpp
@@ -10,68 +10,68 @@
// In-house headers:
#include "MICmdArgContext.h"
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdArgContext constructor.
// Type: Method.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdArgContext::CMICmdArgContext()
-{
-}
+CMICmdArgContext::CMICmdArgContext() {}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdArgContext constructor.
// Type: Method.
-// Args: vrCmdLineArgsRaw - (R) The text description of the arguments options.
+// Args: vrCmdLineArgsRaw - (R) The text description of the arguments
+// options.
// Return: None.
// Throws: None.
//--
CMICmdArgContext::CMICmdArgContext(const CMIUtilString &vrCmdLineArgsRaw)
- : m_strCmdArgsAndOptions(vrCmdLineArgsRaw)
-{
-}
+ : m_strCmdArgsAndOptions(vrCmdLineArgsRaw) {}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdArgContext destructor.
// Type: Method.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdArgContext::~CMICmdArgContext()
-{
-}
+CMICmdArgContext::~CMICmdArgContext() {}
-//++ ------------------------------------------------------------------------------------
-// Details: Retrieve the remainder of the command's argument options left to parse.
+//++
+//------------------------------------------------------------------------------------
+// Details: Retrieve the remainder of the command's argument options left to
+// parse.
// Type: Method.
// Args: None.
// Return: CMIUtilString & - Argument options text.
// Throws: None.
//--
-const CMIUtilString &
-CMICmdArgContext::GetArgsLeftToParse() const
-{
- return m_strCmdArgsAndOptions;
+const CMIUtilString &CMICmdArgContext::GetArgsLeftToParse() const {
+ return m_strCmdArgsAndOptions;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: Ask if this arguments string has any arguments.
// Type: Method.
// Args: None.
-// Return: bool - True = Has one or more arguments present, false = no arguments.
+// Return: bool - True = Has one or more arguments present, false = no
+// arguments.
// Throws: None.
//--
-bool
-CMICmdArgContext::IsEmpty() const
-{
- return m_strCmdArgsAndOptions.empty();
+bool CMICmdArgContext::IsEmpty() const {
+ return m_strCmdArgsAndOptions.empty();
}
-//++ ------------------------------------------------------------------------------------
-// Details: Remove the argument from the options text and any space after the argument
+//++
+//------------------------------------------------------------------------------------
+// Details: Remove the argument from the options text and any space after the
+// argument
// if applicable.
// Type: Method.
// Args: vArg - (R) The name of the argument.
@@ -79,167 +79,154 @@ CMICmdArgContext::IsEmpty() const
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdArgContext::RemoveArg(const CMIUtilString &vArg)
-{
- if (vArg.empty())
- return MIstatus::success;
-
- const size_t nLen = vArg.length();
- const size_t nLenCntxt = m_strCmdArgsAndOptions.length();
- if (nLen > nLenCntxt)
- return MIstatus::failure;
-
- size_t nExtraSpace = 0;
- size_t nPos = m_strCmdArgsAndOptions.find(vArg);
- while (1)
- {
- if (nPos == std::string::npos)
- return MIstatus::success;
-
- bool bPass1 = false;
- if (nPos != 0)
- {
- if (m_strCmdArgsAndOptions[nPos - 1] == ' ')
- bPass1 = true;
- }
- else
- bPass1 = true;
-
- const size_t nEnd = nPos + nLen;
-
- if (bPass1)
- {
- bool bPass2 = false;
- if (nEnd < nLenCntxt)
- {
- if (m_strCmdArgsAndOptions[nEnd] == ' ')
- {
- bPass2 = true;
- nExtraSpace = 1;
- }
- }
- else
- bPass2 = true;
-
- if (bPass2)
- break;
+bool CMICmdArgContext::RemoveArg(const CMIUtilString &vArg) {
+ if (vArg.empty())
+ return MIstatus::success;
+
+ const size_t nLen = vArg.length();
+ const size_t nLenCntxt = m_strCmdArgsAndOptions.length();
+ if (nLen > nLenCntxt)
+ return MIstatus::failure;
+
+ size_t nExtraSpace = 0;
+ size_t nPos = m_strCmdArgsAndOptions.find(vArg);
+ while (1) {
+ if (nPos == std::string::npos)
+ return MIstatus::success;
+
+ bool bPass1 = false;
+ if (nPos != 0) {
+ if (m_strCmdArgsAndOptions[nPos - 1] == ' ')
+ bPass1 = true;
+ } else
+ bPass1 = true;
+
+ const size_t nEnd = nPos + nLen;
+
+ if (bPass1) {
+ bool bPass2 = false;
+ if (nEnd < nLenCntxt) {
+ if (m_strCmdArgsAndOptions[nEnd] == ' ') {
+ bPass2 = true;
+ nExtraSpace = 1;
}
+ } else
+ bPass2 = true;
- nPos = m_strCmdArgsAndOptions.find(vArg, nEnd);
+ if (bPass2)
+ break;
}
- const size_t nPosEnd = nLen + nExtraSpace;
- m_strCmdArgsAndOptions = m_strCmdArgsAndOptions.replace(nPos, nPosEnd, "");
- m_strCmdArgsAndOptions = m_strCmdArgsAndOptions.Trim();
+ nPos = m_strCmdArgsAndOptions.find(vArg, nEnd);
+ }
- return MIstatus::success;
+ const size_t nPosEnd = nLen + nExtraSpace;
+ m_strCmdArgsAndOptions = m_strCmdArgsAndOptions.replace(nPos, nPosEnd, "");
+ m_strCmdArgsAndOptions = m_strCmdArgsAndOptions.Trim();
+
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
-// Details: Remove the argument at the Nth word position along in the context string.
-// Any space after the argument is removed if applicable. A search is not
-// performed as there may be more than one vArg with the same 'name' in the
+//++
+//------------------------------------------------------------------------------------
+// Details: Remove the argument at the Nth word position along in the context
+// string.
+// Any space after the argument is removed if applicable. A search is
+// not
+// performed as there may be more than one vArg with the same 'name' in
+// the
// context string.
// Type: Method.
// Args: vArg - (R) The name of the argument.
-// nArgIndex - (R) The word count position to which to remove the vArg word.
+// nArgIndex - (R) The word count position to which to remove the
+// vArg word.
// Return: MIstatus::success - Functional succeeded.
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdArgContext::RemoveArgAtPos(const CMIUtilString &vArg, size_t nArgIndex)
-{
- size_t nWordIndex = 0;
- CMIUtilString strBuildContextUp;
- const CMIUtilString::VecString_t vecWords(GetArgs());
- const bool bSpaceRequired(GetNumberArgsPresent() > 2);
-
- CMIUtilString::VecString_t::const_iterator it = vecWords.begin();
- const CMIUtilString::VecString_t::const_iterator itEnd = vecWords.end();
- while (it != itEnd)
- {
- const CMIUtilString &rWord(*it);
- if (nWordIndex++ != nArgIndex)
- {
- // Single words
- strBuildContextUp += rWord;
- if (bSpaceRequired)
- strBuildContextUp += " ";
- }
- else
- {
- // If quoted loose quoted text
- if (++it != itEnd)
- {
- CMIUtilString words = rWord;
- while (vArg != words)
- {
- if (bSpaceRequired)
- words += " ";
- words += *it;
- if (++it == itEnd)
- break;
- }
- if (it != itEnd)
- --it;
- }
+bool CMICmdArgContext::RemoveArgAtPos(const CMIUtilString &vArg,
+ size_t nArgIndex) {
+ size_t nWordIndex = 0;
+ CMIUtilString strBuildContextUp;
+ const CMIUtilString::VecString_t vecWords(GetArgs());
+ const bool bSpaceRequired(GetNumberArgsPresent() > 2);
+
+ CMIUtilString::VecString_t::const_iterator it = vecWords.begin();
+ const CMIUtilString::VecString_t::const_iterator itEnd = vecWords.end();
+ while (it != itEnd) {
+ const CMIUtilString &rWord(*it);
+ if (nWordIndex++ != nArgIndex) {
+ // Single words
+ strBuildContextUp += rWord;
+ if (bSpaceRequired)
+ strBuildContextUp += " ";
+ } else {
+ // If quoted loose quoted text
+ if (++it != itEnd) {
+ CMIUtilString words = rWord;
+ while (vArg != words) {
+ if (bSpaceRequired)
+ words += " ";
+ words += *it;
+ if (++it == itEnd)
+ break;
}
-
- // Next
if (it != itEnd)
- ++it;
+ --it;
+ }
}
- m_strCmdArgsAndOptions = strBuildContextUp;
- m_strCmdArgsAndOptions = m_strCmdArgsAndOptions.Trim();
+ // Next
+ if (it != itEnd)
+ ++it;
+ }
- return MIstatus::success;
+ m_strCmdArgsAndOptions = strBuildContextUp;
+ m_strCmdArgsAndOptions = m_strCmdArgsAndOptions.Trim();
+
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
-// Details: Retrieve number of arguments or options present in the command's option text.
+//++
+//------------------------------------------------------------------------------------
+// Details: Retrieve number of arguments or options present in the command's
+// option text.
// Type: Method.
// Args: None.
// Return: size_t - 0 to n arguments present.
// Throws: None.
//--
-size_t
-CMICmdArgContext::GetNumberArgsPresent() const
-{
- CMIUtilString::VecString_t vecOptions;
- return m_strCmdArgsAndOptions.SplitConsiderQuotes(" ", vecOptions);
+size_t CMICmdArgContext::GetNumberArgsPresent() const {
+ CMIUtilString::VecString_t vecOptions;
+ return m_strCmdArgsAndOptions.SplitConsiderQuotes(" ", vecOptions);
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: Retrieve all the arguments or options remaining in *this context.
// Type: Method.
// Args: None.
// Return: MIUtilString::VecString_t - List of args remaining.
// Throws: None.
//--
-CMIUtilString::VecString_t
-CMICmdArgContext::GetArgs() const
-{
- CMIUtilString::VecString_t vecOptions;
- m_strCmdArgsAndOptions.SplitConsiderQuotes(" ", vecOptions);
- return vecOptions;
+CMIUtilString::VecString_t CMICmdArgContext::GetArgs() const {
+ CMIUtilString::VecString_t vecOptions;
+ m_strCmdArgsAndOptions.SplitConsiderQuotes(" ", vecOptions);
+ return vecOptions;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: Copy assignment operator.
// Type: Method.
// Args: vOther - (R) The variable to copy from.
// Return: CMIUtilString & - this object.
// Throws: None.
//--
-CMICmdArgContext &CMICmdArgContext::operator=(const CMICmdArgContext &vOther)
-{
- if (this != &vOther)
- {
- m_strCmdArgsAndOptions = vOther.m_strCmdArgsAndOptions;
- }
+CMICmdArgContext &CMICmdArgContext::operator=(const CMICmdArgContext &vOther) {
+ if (this != &vOther) {
+ m_strCmdArgsAndOptions = vOther.m_strCmdArgsAndOptions;
+ }
- return *this;
+ return *this;
}