本文整理汇总了C++中const_string_set_t类的典型用法代码示例。如果您正苦于以下问题:C++ const_string_set_t类的具体用法?C++ const_string_set_t怎么用?C++ const_string_set_t使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了const_string_set_t类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: env_destroy
void env_destroy()
{
env_universal_destroy();
while (&top->env != global)
{
env_pop();
}
env_read_only.clear();
env_electric.clear();
var_table_t::iterator iter;
for (iter = global->begin(); iter != global->end(); ++iter)
{
const var_entry_t &entry = iter->second;
if (entry.exportv)
{
mark_changed_exported();
break;
}
}
delete top;
}
开发者ID:GarethLewin,项目名称:fish-shell,代码行数:25,代码来源:env.cpp
示例2: env_get_names
wcstring_list_t env_get_names(int flags)
{
scoped_lock lock(env_lock);
wcstring_list_t result;
std::set<wcstring> names;
int show_local = flags & ENV_LOCAL;
int show_global = flags & ENV_GLOBAL;
int show_universal = flags & ENV_UNIVERSAL;
env_node_t *n=top;
const bool show_exported = (flags & ENV_EXPORT) || !(flags & ENV_UNEXPORT);
const bool show_unexported = (flags & ENV_UNEXPORT) || !(flags & ENV_EXPORT);
if (!show_local && !show_global && !show_universal)
{
show_local =show_universal = show_global=1;
}
if (show_local)
{
while (n)
{
if (n == global_env)
break;
add_key_to_string_set(n->env, &names, show_exported, show_unexported);
if (n->new_scope)
break;
else
n = n->next;
}
}
if (show_global)
{
add_key_to_string_set(global_env->env, &names, show_exported, show_unexported);
if (show_unexported)
{
result.insert(result.end(), env_electric.begin(), env_electric.end());
}
if (show_exported)
{
result.push_back(L"COLUMNS");
result.push_back(L"LINES");
}
}
if (show_universal && uvars())
{
const wcstring_list_t uni_list = uvars()->get_names(show_exported, show_unexported);
names.insert(uni_list.begin(), uni_list.end());
}
result.insert(result.end(), names.begin(), names.end());
return result;
}
开发者ID:Aulos,项目名称:fish-shell,代码行数:60,代码来源:env.cpp
示例3: env_init
void env_init(const struct config_paths_t *paths /* or NULL */)
{
/*
env_read_only variables can not be altered directly by the user
*/
const wchar_t * const ro_keys[] =
{
L"status",
L"history",
L"version",
L"_",
L"LINES",
L"COLUMNS",
L"PWD",
//L"SHLVL", // will be inserted a bit lower down
L"FISH_VERSION",
};
for (size_t i=0; i < sizeof ro_keys / sizeof *ro_keys; i++)
{
env_read_only.insert(ro_keys[i]);
}
/*
Names of all dynamically calculated variables
*/
env_electric.insert(L"history");
env_electric.insert(L"status");
env_electric.insert(L"umask");
env_electric.insert(L"COLUMNS");
env_electric.insert(L"LINES");
top = new env_node_t;
global_env = top;
global = &top->env;
/*
Now the environemnt variable handling is set up, the next step
is to insert valid data
*/
/*
Import environment variables
*/
for (char **p = (environ ? environ : __environ); p && *p; p++)
{
const wcstring key_and_val = str2wcstring(*p); //like foo=bar
size_t eql = key_and_val.find(L'=');
if (eql == wcstring::npos)
{
// no equals found
if (is_read_only(key_and_val) || is_electric(key_and_val)) continue;
env_set(key_and_val, L"", ENV_EXPORT | ENV_GLOBAL);
}
else
{
wcstring key = key_and_val.substr(0, eql);
if (is_read_only(key) || is_electric(key)) continue;
wcstring val = key_and_val.substr(eql + 1);
if (variable_is_colon_delimited_array(key))
{
std::replace(val.begin(), val.end(), L':', ARRAY_SEP);
}
env_set(key, val.c_str(), ENV_EXPORT | ENV_GLOBAL);
}
}
/* Set the given paths in the environment, if we have any */
if (paths != NULL)
{
env_set(FISH_DATADIR_VAR, paths->data.c_str(), ENV_GLOBAL);
env_set(FISH_SYSCONFDIR_VAR, paths->sysconf.c_str(), ENV_GLOBAL);
env_set(FISH_HELPDIR_VAR, paths->doc.c_str(), ENV_GLOBAL);
env_set(FISH_BIN_DIR, paths->bin.c_str(), ENV_GLOBAL);
}
/*
Set up the PATH variable
*/
setup_path();
/*
Set up the USER variable
*/
if (env_get_string(L"USER").missing_or_empty())
{
const struct passwd *pw = getpwuid(getuid());
if (pw && pw->pw_name)
{
const wcstring uname = str2wcstring(pw->pw_name);
env_set(L"USER", uname.c_str(), ENV_GLOBAL | ENV_EXPORT);
}
}
/*
Set up the version variables
*/
wcstring version = str2wcstring(get_fish_version());
env_set(L"version", version.c_str(), ENV_GLOBAL);
//.........这里部分代码省略.........
开发者ID:lnsoso,项目名称:fish-shell,代码行数:101,代码来源:env.cpp
示例4: is_electric
static bool is_electric(const wcstring &key)
{
return env_electric.find(key.c_str()) != env_electric.end();
}
开发者ID:lnsoso,项目名称:fish-shell,代码行数:4,代码来源:env.cpp
示例5: is_read_only
static bool is_read_only(const wcstring &key)
{
return env_read_only.find(key.c_str()) != env_read_only.end();
}
开发者ID:lnsoso,项目名称:fish-shell,代码行数:4,代码来源:env.cpp
示例6: env_init
void env_init(const struct config_paths_t *paths /* or NULL */)
{
/*
env_read_only variables can not be altered directly by the user
*/
const wchar_t * const ro_keys[] =
{
L"status",
L"history",
L"version",
L"_",
L"LINES",
L"COLUMNS",
L"PWD",
L"SHLVL",
L"FISH_VERSION",
};
for (size_t i=0; i < sizeof ro_keys / sizeof *ro_keys; i++)
{
env_read_only.insert(ro_keys[i]);
}
/*
HOME and USER should be writeable by root, since this can be a
convenient way to install software.
*/
if (getuid() != 0)
{
env_read_only.insert(L"HOME");
env_read_only.insert(L"USER");
}
/*
Names of all dynamically calculated variables
*/
env_electric.insert(L"history");
env_electric.insert(L"status");
env_electric.insert(L"umask");
top = new env_node_t;
global_env = top;
global = &top->env;
/*
Now the environemnt variable handling is set up, the next step
is to insert valid data
*/
/*
Import environment variables
*/
for (char **p = (environ ? environ : __environ); p && *p; p++)
{
const wcstring key_and_val = str2wcstring(*p); //like foo=bar
size_t eql = key_and_val.find(L'=');
if (eql == wcstring::npos)
{
// no equals found
env_set(key_and_val, L"", ENV_EXPORT);
}
else
{
wcstring key = key_and_val.substr(0, eql);
wcstring val = key_and_val.substr(eql + 1);
if (variable_can_be_array(val))
{
std::replace(val.begin(), val.end(), L':', ARRAY_SEP);
}
env_set(key, val.c_str(), ENV_EXPORT | ENV_GLOBAL);
}
}
/* Set the given paths in the environment, if we have any */
if (paths != NULL)
{
env_set(FISH_DATADIR_VAR, paths->data.c_str(), ENV_GLOBAL | ENV_EXPORT);
env_set(FISH_SYSCONFDIR_VAR, paths->sysconf.c_str(), ENV_GLOBAL | ENV_EXPORT);
env_set(FISH_HELPDIR_VAR, paths->doc.c_str(), ENV_GLOBAL | ENV_EXPORT);
env_set(FISH_BIN_DIR, paths->bin.c_str(), ENV_GLOBAL | ENV_EXPORT);
}
/*
Set up the PATH variable
*/
setup_path();
/*
Set up the USER variable
*/
const struct passwd *pw = getpwuid(getuid());
if (pw && pw->pw_name)
{
const wcstring uname = str2wcstring(pw->pw_name);
env_set(L"USER", uname.c_str(), ENV_GLOBAL | ENV_EXPORT);
}
/*
Set up the version variables
//.........这里部分代码省略.........
开发者ID:GarethLewin,项目名称:fish-shell,代码行数:101,代码来源:env.cpp
注:本文中的const_string_set_t类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论