summaryrefslogtreecommitdiffstats
path: root/lldb/source/Core/StringList.cpp
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2012-08-22 17:17:09 +0000
committerGreg Clayton <gclayton@apple.com>2012-08-22 17:17:09 +0000
commit67cc06366cdb20795d21c31f89624d81e97af799 (patch)
tree43edfb98f1f542853282474c9685a5e071d2e1d9 /lldb/source/Core/StringList.cpp
parent40dd4d9bf396f17b28fe823160f3e103d2943cfb (diff)
downloadbcm5719-llvm-67cc06366cdb20795d21c31f89624d81e97af799.tar.gz
bcm5719-llvm-67cc06366cdb20795d21c31f89624d81e97af799.zip
Reimplemented the code that backed the "settings" in lldb. There were many issues with the previous implementation:
- no setting auto completion - very manual and error prone way of getting/setting variables - tons of code duplication - useless instance names for processes, threads Now settings can easily be defined like option values. The new settings makes use of the "OptionValue" classes so we can re-use the option value code that we use to set settings in command options. No more instances, just "does the right thing". llvm-svn: 162366
Diffstat (limited to 'lldb/source/Core/StringList.cpp')
-rw-r--r--lldb/source/Core/StringList.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/lldb/source/Core/StringList.cpp b/lldb/source/Core/StringList.cpp
index c4356e7eccc..dae1c817ba5 100644
--- a/lldb/source/Core/StringList.cpp
+++ b/lldb/source/Core/StringList.cpp
@@ -50,6 +50,12 @@ StringList::AppendString (const char *str)
}
void
+StringList::AppendString (const std::string &s)
+{
+ m_strings.push_back (s);
+}
+
+void
StringList::AppendString (const char *str, size_t str_len)
{
if (str)
@@ -253,3 +259,27 @@ StringList::operator << (StringList strings)
AppendList(strings);
return *this;
}
+
+size_t
+StringList::AutoComplete (const char *s, StringList &matches, size_t &exact_idx) const
+{
+ matches.Clear();
+ exact_idx = SIZE_MAX;
+ if (s && s[0])
+ {
+ const size_t s_len = strlen (s);
+ const size_t num_strings = m_strings.size();
+
+ for (size_t i=0; i<num_strings; ++i)
+ {
+ if (m_strings[i].find(s) == 0)
+ {
+ if (exact_idx == SIZE_MAX && m_strings[i].size() == s_len)
+ exact_idx = matches.GetSize();
+ matches.AppendString (m_strings[i]);
+ }
+ }
+ }
+ return matches.GetSize();
+}
+
OpenPOWER on IntegriCloud