本文整理汇总了C++中StringList::AppendString方法的典型用法代码示例。如果您正苦于以下问题:C++ StringList::AppendString方法的具体用法?C++ StringList::AppendString怎么用?C++ StringList::AppendString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringList
的用法示例。
在下文中一共展示了StringList::AppendString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
bool
TargetInstanceSettings::GetInstanceSettingsValue (const SettingEntry &entry,
const ConstString &var_name,
StringList &value,
Error *err)
{
if (var_name == GetSettingNameForExpressionPrefix ())
{
value.AppendString (m_expr_prefix_path.c_str(), m_expr_prefix_path.size());
}
else if (var_name == GetSettingNameForExecutionLevel ())
{
value.AppendString (UserSettingsController::EnumToString (entry.enum_values, m_execution_level));
}
else if (var_name == GetSettingNameForExecutionMode ())
{
value.AppendString (UserSettingsController::EnumToString (entry.enum_values, m_execution_mode));
}
else if (var_name == GetSettingNameForExecutionOSType ())
{
value.AppendString (UserSettingsController::EnumToString (entry.enum_values, m_execution_os_type));
}
else
{
if (err)
err->SetErrorStringWithFormat ("unrecognized variable name '%s'", var_name.AsCString());
return false;
}
return true;
}
示例2: strlen
size_t
OptionValueEnumeration::AutoComplete (CommandInterpreter &interpreter,
const char *s,
int match_start_point,
int max_return_elements,
bool &word_complete,
StringList &matches)
{
word_complete = false;
matches.Clear();
const uint32_t num_enumerators = m_enumerations.GetSize();
if (s && s[0])
{
const size_t s_len = strlen(s);
for (size_t i=0; i<num_enumerators; ++i)
{
const char *name = m_enumerations.GetCStringAtIndex(i);
if (::strncmp(s, name, s_len) == 0)
matches.AppendString(name);
}
}
else
{
// only suggest "true" or "false" by default
for (size_t i=0; i<num_enumerators; ++i)
matches.AppendString(m_enumerations.GetCStringAtIndex(i));
}
return matches.GetSize();
}
示例3: AproposAllSubCommands
void
CommandInterpreter::AproposAllSubCommands (CommandObject *cmd_obj, const char *prefix, const char *search_word,
StringList &commands_found, StringList &commands_help)
{
CommandObject::CommandMap::const_iterator pos;
CommandObject::CommandMap sub_cmd_dict = ((CommandObjectMultiword *) cmd_obj)->m_subcommand_dict;
CommandObject *sub_cmd_obj;
for (pos = sub_cmd_dict.begin(); pos != sub_cmd_dict.end(); ++pos)
{
const char * command_name = pos->first.c_str();
sub_cmd_obj = pos->second.get();
StreamString complete_command_name;
complete_command_name.Printf ("%s %s", prefix, command_name);
if (sub_cmd_obj->HelpTextContainsWord (search_word))
{
commands_found.AppendString (complete_command_name.GetData());
commands_help.AppendString (sub_cmd_obj->GetHelp());
}
if (sub_cmd_obj->IsMultiwordObject())
AproposAllSubCommands (sub_cmd_obj, complete_command_name.GetData(), search_word, commands_found,
commands_help);
}
}
示例4: DoExecute
bool DoExecute(Args &command, CommandReturnObject &result) override {
StringList commands;
commands.AppendString("thread backtrace");
Thread *thread = m_exe_ctx.GetThreadPtr();
if (thread) {
char command_buffer[256];
uint32_t frame_count = thread->GetStackFrameCount();
for (uint32_t i = 0; i < frame_count; ++i) {
StackFrameSP frame = thread->GetStackFrameAtIndex(i);
lldb::addr_t pc = frame->GetStackID().GetPC();
snprintf(command_buffer, sizeof(command_buffer),
"disassemble --bytes --address 0x%" PRIx64, pc);
commands.AppendString(command_buffer);
snprintf(command_buffer, sizeof(command_buffer),
"image show-unwind --address 0x%" PRIx64, pc);
commands.AppendString(command_buffer);
}
}
const FileSpec &outfile_spec =
m_outfile_options.GetFile().GetCurrentValue();
if (outfile_spec) {
char path[PATH_MAX];
outfile_spec.GetPath(path, sizeof(path));
uint32_t open_options =
File::eOpenOptionWrite | File::eOpenOptionCanCreate |
File::eOpenOptionAppend | File::eOpenOptionCloseOnExec;
const bool append = m_outfile_options.GetAppend().GetCurrentValue();
if (!append)
open_options |= File::eOpenOptionTruncate;
StreamFileSP outfile_stream = std::make_shared<StreamFile>();
Status error = outfile_stream->GetFile().Open(path, open_options);
if (error.Fail()) {
result.AppendErrorWithFormat("Failed to open file '%s' for %s: %s\n",
path, append ? "append" : "write",
error.AsCString());
result.SetStatus(eReturnStatusFailed);
return false;
}
result.SetImmediateOutputStream(outfile_stream);
}
CommandInterpreterRunOptions options;
options.SetStopOnError(false);
options.SetEchoCommands(true);
options.SetPrintResults(true);
options.SetAddToHistory(false);
m_interpreter.HandleCommands(commands, &m_exe_ctx, options, result);
return result.Succeeded();
}
示例5: AutoCompleteChannelName
void Log::AutoCompleteChannelName(const char *channel_name,
StringList &matches) {
LogChannelMap &map = GetChannelMap();
LogChannelMapIter pos, end = map.end();
for (pos = map.begin(); pos != end; ++pos) {
const char *pos_channel_name = pos->first.GetCString();
if (channel_name && channel_name[0]) {
if (NameMatches(channel_name, eNameMatchStartsWith, pos_channel_name)) {
matches.AppendString(pos_channel_name);
}
} else
matches.AppendString(pos_channel_name);
}
}
示例6: tmp_buf
size_t
FileSpec::ResolvePartialUsername (const char *partial_name, StringList &matches)
{
#ifdef LLDB_CONFIG_TILDE_RESOLVES_TO_USER
size_t extant_entries = matches.GetSize();
setpwent();
struct passwd *user_entry;
const char *name_start = partial_name + 1;
std::set<std::string> name_list;
while ((user_entry = getpwent()) != NULL)
{
if (strstr(user_entry->pw_name, name_start) == user_entry->pw_name)
{
std::string tmp_buf("~");
tmp_buf.append(user_entry->pw_name);
tmp_buf.push_back('/');
name_list.insert(tmp_buf);
}
}
std::set<std::string>::iterator pos, end = name_list.end();
for (pos = name_list.begin(); pos != end; pos++)
{
matches.AppendString((*pos).c_str());
}
return matches.GetSize() - extant_entries;
#else
// Resolving home directories is not supported, just copy the path...
return 0;
#endif // #ifdef LLDB_CONFIG_TILDE_RESOLVES_TO_USER
}
示例7: strlen
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]);
}
}
}
else
{
// No string, so it matches everything
matches = *this;
}
return matches.GetSize();
}
示例8: GetEnvironment
size_t Host::GetEnvironment(StringList &env) {
char **host_env = environ;
char *env_entry;
size_t i;
for (i = 0; (env_entry = host_env[i]) != NULL; ++i)
env.AppendString(env_entry);
return i;
}
示例9: strlen
size_t
OptionValueBoolean::AutoComplete (CommandInterpreter &interpreter,
const char *s,
int match_start_point,
int max_return_elements,
bool &word_complete,
StringList &matches)
{
word_complete = false;
matches.Clear();
struct StringEntry {
const char *string;
const size_t length;
};
static const StringEntry g_autocomplete_entries[] =
{
{ "true" , 4 },
{ "false", 5 },
{ "on" , 2 },
{ "off" , 3 },
{ "yes" , 3 },
{ "no" , 2 },
{ "1" , 1 },
{ "0" , 1 },
};
const size_t k_num_autocomplete_entries = llvm::array_lengthof(g_autocomplete_entries);
if (s && s[0])
{
const size_t s_len = strlen(s);
for (size_t i=0; i<k_num_autocomplete_entries; ++i)
{
if (s_len <= g_autocomplete_entries[i].length)
if (::strncasecmp(s, g_autocomplete_entries[i].string, s_len) == 0)
matches.AppendString(g_autocomplete_entries[i].string);
}
}
else
{
// only suggest "true" or "false" by default
for (size_t i=0; i<2; ++i)
matches.AppendString(g_autocomplete_entries[i].string);
}
return matches.GetSize();
}
示例10:
uint32_t
ArchSpec::AutoComplete (const char *name, StringList &matches)
{
uint32_t i;
if (name && name[0])
{
for (i = 0; i < ArchSpec::kNumCores; ++i)
{
if (NameMatches(g_core_definitions[i].name, eNameMatchStartsWith, name))
matches.AppendString (g_core_definitions[i].name);
}
}
else
{
for (i = 0; i < ArchSpec::kNumCores; ++i)
matches.AppendString (g_core_definitions[i].name);
}
return matches.GetSize();
}
示例11: defined
uint32_t
Host::ListProcessesMatchingName (const char *name, StringList &matches, std::vector<lldb::pid_t> &pids)
{
uint32_t num_matches = 0;
#if defined (__APPLE__)
int num_pids;
int size_of_pids;
std::vector<int> pid_list;
size_of_pids = proc_listpids(PROC_ALL_PIDS, 0, NULL, 0);
if (size_of_pids == -1)
return 0;
num_pids = size_of_pids/sizeof(int);
pid_list.resize (size_of_pids);
size_of_pids = proc_listpids(PROC_ALL_PIDS, 0, &pid_list[0], size_of_pids);
if (size_of_pids == -1)
return 0;
lldb::pid_t our_pid = getpid();
for (int i = 0; i < num_pids; i++)
{
struct proc_bsdinfo bsd_info;
int error = proc_pidinfo (pid_list[i], PROC_PIDTBSDINFO, (uint64_t) 0, &bsd_info, PROC_PIDTBSDINFO_SIZE);
if (error == 0)
continue;
// Don't offer to attach to zombie processes, already traced or exiting
// processes, and of course, ourselves... It looks like passing the second arg of
// 0 to proc_listpids will exclude zombies anyway, but that's not documented so...
if (((bsd_info.pbi_flags & (PROC_FLAG_TRACED | PROC_FLAG_INEXIT)) != 0)
|| (bsd_info.pbi_status == SZOMB)
|| (bsd_info.pbi_pid == our_pid))
continue;
char pid_name[MAXCOMLEN * 2 + 1];
int name_len;
name_len = proc_name(bsd_info.pbi_pid, pid_name, MAXCOMLEN * 2);
if (name_len == 0)
continue;
if (strstr(pid_name, name) != pid_name)
continue;
matches.AppendString (pid_name);
pids.push_back (bsd_info.pbi_pid);
num_matches++;
}
#endif
return num_matches;
}
示例12: IOHandlerComplete
int REPL::IOHandlerComplete(IOHandler &io_handler, const char *current_line,
const char *cursor, const char *last_char,
int skip_first_n_matches, int max_matches,
StringList &matches) {
matches.Clear();
llvm::StringRef line(current_line, cursor - current_line);
// Complete an LLDB command if the first character is a colon...
if (!line.empty() && line[0] == ':') {
Debugger &debugger = m_target.GetDebugger();
// auto complete LLDB commands
const char *lldb_current_line = line.substr(1).data();
return debugger.GetCommandInterpreter().HandleCompletion(
lldb_current_line, cursor, last_char, skip_first_n_matches, max_matches,
matches);
}
// Strip spaces from the line and see if we had only spaces
line = line.ltrim();
if (line.empty()) {
// Only spaces on this line, so just indent
matches.AppendString(m_indent_str);
return 1;
}
std::string current_code;
current_code.append(m_code.CopyList());
IOHandlerEditline &editline = static_cast<IOHandlerEditline &>(io_handler);
const StringList *current_lines = editline.GetCurrentLines();
if (current_lines) {
const uint32_t current_line_idx = editline.GetCurrentLineIndex();
if (current_line_idx < current_lines->GetSize()) {
for (uint32_t i = 0; i < current_line_idx; ++i) {
const char *line_cstr = current_lines->GetStringAtIndex(i);
if (line_cstr) {
current_code.append("\n");
current_code.append(line_cstr);
}
}
}
}
if (cursor > current_line) {
current_code.append("\n");
current_code.append(current_line, cursor - current_line);
}
return CompleteCode(current_code, matches);
}
示例13: strchr
size_t
Host::GetEnvironment (StringList &env)
{
char *v;
char **var = environ;
for (; var != NULL && *var != NULL; ++var)
{
v = strchr(*var, (int)'-');
if (v == NULL)
continue;
env.AppendString(v);
}
return env.GetSize();
}
示例14: current_var
size_t
Host::GetEnvironment(StringList &env)
{
// The environment block on Windows is a contiguous buffer of NULL terminated strings,
// where the end of the environment block is indicated by two consecutive NULLs.
LPCH environment_block = ::GetEnvironmentStrings();
env.Clear();
while (*environment_block != '\0')
{
llvm::StringRef current_var(environment_block);
if (current_var[0] != '=')
env.AppendString(current_var);
environment_block += current_var.size()+1;
}
return env.GetSize();
}
示例15: exe_ctx
size_t
OptionValueUUID::AutoComplete (CommandInterpreter &interpreter,
const char *s,
int match_start_point,
int max_return_elements,
bool &word_complete,
StringList &matches)
{
word_complete = false;
matches.Clear();
ExecutionContext exe_ctx(interpreter.GetExecutionContext());
Target *target = exe_ctx.GetTargetPtr();
if (target)
{
const size_t num_modules = target->GetImages().GetSize();
if (num_modules > 0)
{
UUID::ValueType uuid_bytes;
const size_t num_bytes_decoded = UUID::DecodeUUIDBytesFromCString(s, uuid_bytes, NULL);
for (size_t i=0; i<num_modules; ++i)
{
ModuleSP module_sp (target->GetImages().GetModuleAtIndex(i));
if (module_sp)
{
const UUID &module_uuid = module_sp->GetUUID();
if (module_uuid.IsValid())
{
bool add_uuid = false;
if (num_bytes_decoded == 0)
add_uuid = true;
else
add_uuid = ::memcmp(module_uuid.GetBytes(), uuid_bytes, num_bytes_decoded) == 0;
if (add_uuid)
{
std::string uuid_str;
uuid_str = module_uuid.GetAsString();
if (!uuid_str.empty())
matches.AppendString(uuid_str.c_str());
}
}
}
}
}
}
return matches.GetSize();
}