本文整理汇总了C++中StringList::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ StringList::insert方法的具体用法?C++ StringList::insert怎么用?C++ StringList::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringList
的用法示例。
在下文中一共展示了StringList::insert方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fillForwardList
// Get header info from options and store in map for processing with
// metadata.
void LasWriter::fillForwardList()
{
static const StringList header = {
"dataformat_id", "major_version", "minor_version", "filesource_id",
"global_encoding", "project_id", "system_id", "software_id",
"creation_doy", "creation_year"
};
static const StringList scale = { "scale_x", "scale_y", "scale_z" };
static const StringList offset = { "offset_x", "offset_y", "offset_z" };
static StringList all;
all.insert(all.begin(), header.begin(), header.end());
all.insert(all.begin(), scale.begin(), scale.end());
all.insert(all.begin(), offset.begin(), offset.end());
// Build the forward list, replacing special keywords with the proper
// field names.
for (auto& name : m_forwardSpec)
{
if (name == "all")
{
m_forwards.insert(all.begin(), all.end());
m_forwardVlrs = true;
}
else if (name == "header")
m_forwards.insert(header.begin(), header.end());
else if (name == "scale")
m_forwards.insert(scale.begin(), scale.end());
else if (name == "offset")
m_forwards.insert(offset.begin(), offset.end());
else if (name == "format")
m_forwards.insert("dataformat_id");
else if (name == "vlr")
m_forwardVlrs = true;
else if (Utils::contains(all, name))
m_forwards.insert(name);
else
{
std::ostringstream oss;
oss << "Error in 'forward' option. Unknown field for "
"forwarding: '" << name << "'.";
throw pdal_error(oss.str());
}
}
}
示例2: findSubfolders
void et::findSubfolders(const std::string& folder, bool recursive, StringList& list)
{
StringList folderList;
ET_STRING_TYPE normalizedFolder = ET_STRING_TO_PARAM_TYPE(addTrailingSlash(folder));
ET_STRING_TYPE foldersSearchPath = normalizedFolder + allFilesMask;
WIN32_FIND_DATA folders = { };
HANDLE folderSearch = FindFirstFile(foldersSearchPath.c_str(), &folders);
if (folderSearch != INVALID_HANDLE_VALUE)
{
do
{
ET_STRING_TYPE name(folders.cFileName);
bool isFolder = (folders.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY;
if (isFolder && (name != currentFolder) && (name != previousFolder))
{
folderList.push_back(ET_STRING_TO_OUTPUT_TYPE(normalizedFolder +
name + ET_STRING_FROM_CONST_CHAR("\\")));
}
}
while (FindNextFile(folderSearch, &folders));
FindClose(folderSearch);
}
if (recursive)
{
for (const std::string& i : folderList)
findSubfolders(i, true, list);
}
list.insert(list.end(), folderList.begin(), folderList.end());
}
示例3: findSubfolders
void et::findSubfolders(const std::string& folder, bool recursive, StringList& list)
{
std::string normalizedFolder = addTrailingSlash(folder);
std::string foldersSearchPath = normalizedFolder + "*.*";
StringList folderList;
WIN32_FIND_DATA folders = { };
HANDLE folderSearch = FindFirstFile(foldersSearchPath.c_str(), &folders);
if (folderSearch != INVALID_HANDLE_VALUE)
{
do
{
if (strcmp(folders.cFileName, ".") && strcmp(folders.cFileName, "..") &&
((folders.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY))
{
std::string folderName(folders.cFileName);
folderList.push_back(normalizedFolder + folderName + "\\");
}
}
while (FindNextFile(folderSearch, &folders));
FindClose(folderSearch);
}
if (recursive)
{
for (const std::string& i : folderList)
findSubfolders(i, true, list);
}
list.insert(list.end(), folderList.begin(), folderList.end());
}
示例4: main
int main ()
{
// Create a list of critters.
StringList critters;
// Insert a few critters.
critters.insert (critters.begin (), "antelope");
critters.insert (critters.begin (), "bear");
critters.insert (critters.begin (), "cat");
// Print out the list.
std::cout << critters << '\n';
// Change cat to cougar.
*std::find (critters.begin (),critters.end (), "cat") = "cougar";
std::cout << critters << '\n';
// Put a zebra at the beginning, an ocelot ahead of antelope,
// and a rat at the end.
critters.push_front ("zebra");
critters.insert (std::find (critters.begin (), critters.end (),
"antelope"), "ocelot");
critters.push_back ("rat");
std::cout << critters << '\n';
// Sort the list (Use list's sort function since the
// generic algorithm requires a random access iterator
// and list only provides bidirectional)
critters.sort ();
std::cout << critters << '\n';
// Now let's erase half of the critters.
StringList::size_type half = critters.size () / 2;
for (StringList::size_type i = 0; i != half; ++i)
critters.erase (critters.begin ());
std::cout << critters << '\n';
return 0;
}
示例5:
void
Slice::ObjCGenerator::MetaDataVisitor::setMetaData(const ContainedPtr& cont, const StringList& metadata)
{
StringList localMetaData = cont->getMetaData();
for(StringList::const_iterator p = localMetaData.begin(); p != localMetaData.end();)
{
string s = *p++;
if(s.find(_objcPrefix) == 0)
{
localMetaData.remove(s);
}
}
localMetaData.insert(localMetaData.end(), metadata.begin(), metadata.end());
cont->setMetaData(localMetaData);
}
示例6: builtinDefinitionFiles
StringList EntityDefinitionManager::builtinDefinitionFiles() {
StringList result;
IO::FileManager fileManager;
const String resourcePath = fileManager.resourceDirectory();
const String defPath = fileManager.appendPathComponent(resourcePath, "Defs");
const StringList defFiles = fileManager.directoryContents(defPath, "def");
const StringList fgdFiles = fileManager.directoryContents(defPath, "fgd");
result.insert(result.end(), defFiles.begin(), defFiles.end());
result.insert(result.end(), fgdFiles.begin(), fgdFiles.end());
std::sort(result.begin(), result.end());
return result;
}
示例7:
int
main(int argc, char **argv)
{
StringList stringList;
StringList::iterator pos;
stringList.push_back(&a);
stringList.push_back(&b);
pos = stringList.begin();
stringList.insert(pos, &c);
for (pos = stringList.begin(); pos != stringList.end(); ++pos) {
cout << *pos << endl;
string *s = *pos;
cout << s->c_str() << (*pos)->c_str() << endl;
}
for (pos = stringList.begin(); pos != stringList.end(); ) {
cout << *pos << endl;
pos = stringList.erase(pos);
}
}
示例8: loadProgramSources
StringList ProgramFactory::loadProgramSources(const std::string& file, std::string& vertex_shader,
std::string& geom_shader, std::string& frag_shader, const StringList& defines)
{
StringList sources;
std::string filename = application().resolveFileName(file);
if (!fileExists(filename))
{
log::error("Unable to find file: %s", file.c_str());
return sources;
}
StringList resultDefines = defines;
std::string vertex_source;
std::string geometry_source;
std::string fragment_source;
std::string s;
InputStream progFile(filename, StreamMode_Binary);
while (!(progFile.stream().eof() || progFile.stream().fail()))
{
getline(progFile.stream(), s);
trim(s);
std::string id = s.substr(0, s.find(':'));
trim(id);
lowercase(id);
if (id == "vs")
vertex_source = s.substr(s.find_first_of(':') + 1);
if (id == "gs")
geometry_source = s.substr(s.find_first_of(':') + 1);
if (id == "fs")
fragment_source = s.substr(s.find_first_of(':') + 1);
if (id == "defines")
{
StringList aDefines = parseDefinesString(s.substr(s.find_first_of(':') + 1));
resultDefines.insert(resultDefines.end(), aDefines.begin(), aDefines.end());
}
}
normalizeFilePath(trim(vertex_source));
normalizeFilePath(trim(geometry_source));
normalizeFilePath(trim(fragment_source));
std::string programFolder = getFilePath(filename);
std::string fName = programFolder + vertex_source;
if (!fileExists(fName))
fName = application().resolveFileName(fName);
if (!fileExists(fName))
fName = application().resolveFileName(vertex_source);
if (fileExists(fName))
{
sources.push_back(fName);
vertex_shader = loadTextFile(fName);
ET_ASSERT((vertex_shader.size() > 1) && "Vertex shader source should not be empty");
}
if (!geometry_source.empty())
{
fName = programFolder + geometry_source;
if (!fileExists(fName))
fName = application().resolveFileName(fName);
if (!fileExists(fName))
fName = application().resolveFileName(geometry_source);
if (fileExists(fName))
{
geom_shader = loadTextFile(fName);
sources.push_back(fName);
}
}
fName = programFolder + fragment_source;
if (!fileExists(fName))
fName = application().resolveFileName(fName);
if (!fileExists(fName))
fName = application().resolveFileName(fragment_source);
if (fileExists(fName))
{
sources.push_back(fName);
frag_shader = loadTextFile(fName);
ET_ASSERT((frag_shader.size() > 1) && "Fragment shader source should not be empty");
}
return sources;
}
示例9: SetAttrListPrintMaskFromStream
//.........这里部分代码省略.........
int kw = pkw->value;
if ( ! got_attr) {
toke.copy_marked(attr);
got_attr = true;
}
switch (kw) {
case kw_AS: {
if (toke.next()) {
toke.copy_token(name);
if (toke.is_quoted_string()) { collapse_escapes(name); }
} else {
expected_token(error_message, "column name after AS", "SELECT", stream, toke);
}
toke.mark_after();
} break;
case kw_PRINTF: {
if (toke.next()) {
std::string val; toke.copy_token(val);
fmt = mask.store(val.c_str());
} else {
expected_token(error_message, "format after PRINTF", "SELECT", stream, toke);
}
} break;
case kw_PRINTAS: {
if (toke.next()) {
const CustomFormatFnTableItem * pcffi = FnTable.find_match(toke);
if (pcffi) {
cust = pcffi->cust;
//cust_type = pcffi->cust;
const char * pszz = pcffi->extra_attribs;
if (pszz) {
size_t cch = strlen(pszz);
while (cch > 0) { attrs.insert(pszz); pszz += cch+1; cch = strlen(pszz); }
}
} else {
std::string aa; toke.copy_token(aa);
formatstr_cat(error_message, "Unknown argument %s for PRINTAS\n", aa.c_str());
}
} else {
expected_token(error_message, "function name after PRINTAS", "SELECT", stream, toke);
}
} break;
case kw_NOSUFFIX: {
opts |= FormatOptionNoSuffix;
} break;
case kw_NOPREFIX: {
opts |= FormatOptionNoPrefix;
} break;
case kw_LEFT: {
opts |= FormatOptionLeftAlign;
} break;
case kw_RIGHT: {
opts &= ~FormatOptionLeftAlign;
} break;
case kw_TRUNCATE: {
opts &= ~FormatOptionNoTruncate;
} break;
case kw_WIDTH: {
if (toke.next()) {
std::string val; toke.copy_token(val);
if (toke.matches("AUTO")) {
opts |= FormatOptionAutoWidth;
} else {
wid = atoi(val.c_str());
//if (wid) opts &= ~FormatOptionAutoWidth;
示例10: loadCertificates
void CryptoManager::loadCertificates() throw() {
if(!BOOLSETTING(USE_TLS))
return;
SSL_CTX_set_verify(serverContext, SSL_VERIFY_NONE, 0);
SSL_CTX_set_verify(clientContext, SSL_VERIFY_NONE, 0);
SSL_CTX_set_verify(clientVerContext, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, 0);
SSL_CTX_set_verify(serverVerContext, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, 0);
const string& cert = SETTING(TLS_CERTIFICATE_FILE);
const string& key = SETTING(TLS_PRIVATE_KEY_FILE);
if(cert.empty() || key.empty()) {
LogManager::getInstance()->message(STRING(NO_CERTIFICATE_FILE_SET));
return;
}
if(File::getSize(cert) == -1 || File::getSize(key) == -1) {
// Try to generate them...
try {
generateCertificate();
} catch(const CryptoException& e) {
LogManager::getInstance()->message(STRING(CERTIFICATE_GENERATION_FAILED) + e.getError());
}
}
if(SSL_CTX_use_certificate_file(serverContext, SETTING(TLS_CERTIFICATE_FILE).c_str(), SSL_FILETYPE_PEM) != SSL_SUCCESS) {
LogManager::getInstance()->message(STRING(FAILED_TO_LOAD_CERTIFICATE));
return;
}
if(SSL_CTX_use_certificate_file(clientContext, SETTING(TLS_CERTIFICATE_FILE).c_str(), SSL_FILETYPE_PEM) != SSL_SUCCESS) {
LogManager::getInstance()->message(STRING(FAILED_TO_LOAD_CERTIFICATE));
return;
}
if(SSL_CTX_use_certificate_file(serverVerContext, SETTING(TLS_CERTIFICATE_FILE).c_str(), SSL_FILETYPE_PEM) != SSL_SUCCESS) {
LogManager::getInstance()->message(STRING(FAILED_TO_LOAD_CERTIFICATE));
return;
}
if(SSL_CTX_use_certificate_file(clientVerContext, SETTING(TLS_CERTIFICATE_FILE).c_str(), SSL_FILETYPE_PEM) != SSL_SUCCESS) {
LogManager::getInstance()->message(STRING(FAILED_TO_LOAD_CERTIFICATE));
return;
}
if(SSL_CTX_use_PrivateKey_file(serverContext, SETTING(TLS_PRIVATE_KEY_FILE).c_str(), SSL_FILETYPE_PEM) != SSL_SUCCESS) {
LogManager::getInstance()->message(STRING(FAILED_TO_LOAD_PRIVATE_KEY));
return;
}
if(SSL_CTX_use_PrivateKey_file(clientContext, SETTING(TLS_PRIVATE_KEY_FILE).c_str(), SSL_FILETYPE_PEM) != SSL_SUCCESS) {
LogManager::getInstance()->message(STRING(FAILED_TO_LOAD_PRIVATE_KEY));
return;
}
if(SSL_CTX_use_PrivateKey_file(serverVerContext, SETTING(TLS_PRIVATE_KEY_FILE).c_str(), SSL_FILETYPE_PEM) != SSL_SUCCESS) {
LogManager::getInstance()->message(STRING(FAILED_TO_LOAD_PRIVATE_KEY));
return;
}
if(SSL_CTX_use_PrivateKey_file(clientVerContext, SETTING(TLS_PRIVATE_KEY_FILE).c_str(), SSL_FILETYPE_PEM) != SSL_SUCCESS) {
LogManager::getInstance()->message(STRING(FAILED_TO_LOAD_PRIVATE_KEY));
return;
}
StringList certs = File::findFiles(SETTING(TLS_TRUSTED_CERTIFICATES_PATH), "*.pem");
StringList certs2 = File::findFiles(SETTING(TLS_TRUSTED_CERTIFICATES_PATH), "*.crt");
certs.insert(certs.end(), certs2.begin(), certs2.end());
for(StringIter i = certs.begin(); i != certs.end(); ++i) {
if(
SSL_CTX_load_verify_locations(clientContext, i->c_str(), NULL) != SSL_SUCCESS ||
SSL_CTX_load_verify_locations(clientVerContext, i->c_str(), NULL) != SSL_SUCCESS ||
SSL_CTX_load_verify_locations(serverContext, i->c_str(), NULL) != SSL_SUCCESS ||
SSL_CTX_load_verify_locations(serverVerContext, i->c_str(), NULL) != SSL_SUCCESS
) {
LogManager::getInstance()->message("Failed to load trusted certificate from " + *i);
}
}
certsLoaded = true;
}