这篇教程C++ CoreException函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中CoreException函数的典型用法代码示例。如果您正苦于以下问题:C++ CoreException函数的具体用法?C++ CoreException怎么用?C++ CoreException使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了CoreException函数的24个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: CoreExceptionvoid ParseStack::DoInclude(ConfigTag* tag, int flags){ if (flags & FLAG_NO_INC) throw CoreException("Invalid <include> tag in file included with noinclude=/"yes/""); std::string mandatorytag; tag->readString("mandatorytag", mandatorytag); std::string name; if (tag->readString("file", name)) { if (tag->getBool("noinclude", false)) flags |= FLAG_NO_INC; if (tag->getBool("noexec", false)) flags |= FLAG_NO_EXEC; if (!ParseFile(ServerInstance->Config->Paths.PrependConfig(name), flags, mandatorytag)) throw CoreException("Included"); } else if (tag->readString("executable", name)) { if (flags & FLAG_NO_EXEC) throw CoreException("Invalid <include:executable> tag in file included with noexec=/"yes/""); if (tag->getBool("noinclude", false)) flags |= FLAG_NO_INC; if (tag->getBool("noexec", true)) flags |= FLAG_NO_EXEC; if (!ParseFile(name, flags, mandatorytag, true)) throw CoreException("Included"); }}
开发者ID:KeiroD,项目名称:inspircd,代码行数:30,
示例2: socketSocketThread::SocketThread(){ int listenFD = socket(AF_INET, SOCK_STREAM, 0); if (listenFD == -1) throw CoreException("Could not create ITC pipe"); int connFD = socket(AF_INET, SOCK_STREAM, 0); if (connFD == -1) throw CoreException("Could not create ITC pipe"); if (!BindAndListen(listenFD, 0, "127.0.0.1")) throw CoreException("Could not create ITC pipe"); SocketEngine::NonBlocking(connFD); struct sockaddr_in addr; socklen_t sz = sizeof(addr); getsockname(listenFD, reinterpret_cast<struct sockaddr*>(&addr), &sz); connect(connFD, reinterpret_cast<struct sockaddr*>(&addr), sz); SocketEngine::Blocking(listenFD); int nfd = accept(listenFD, reinterpret_cast<struct sockaddr*>(&addr), &sz); if (nfd < 0) throw CoreException("Could not create ITC pipe"); new ThreadSignalSocket(this, nfd); closesocket(listenFD); SocketEngine::Blocking(connFD); this->signal.connFD = connFD;}
开发者ID:Canternet,项目名称:inspircd,代码行数:27,
示例3: CoreExceptionvoid RawFile::load_data(std::ifstream &file, unsigned int rows, unsigned int cols, float *array, unsigned int offset){ // For each of the rows, attempt to read and parse the line. for (unsigned int r = 0; r < rows; r++) { if (file.eof()) { throw CoreException(); } std::string line; std::getline(file, line); // Split the line by ' ', attempt to convert each token into a float, and assign the value in // the array, if successful. std::vector<std::string> items = split_string_by_space(line); if (items.size() != cols) { throw CoreException(); } for (unsigned int c = 0; c < cols; c++) { try { array[offset + (r * cols + c)] = std::stof(items[c]); } catch (std::exception &err) { throw CoreException(); } } }}
开发者ID:kylewray,项目名称:librbr,代码行数:27,
示例4: Log/** * /fn void ModuleHandler::SanitizeRuntime() * /brief Deletes all files in the runtime directory. */void ModuleHandler::SanitizeRuntime(){ Log(LOG_DEBUG) << "Cleaning up runtime directory."; Flux::string dirbuf = binary_dir + "/runtime/"; if(!TextFile::IsDirectory(dirbuf)) {#ifndef _WIN32 if(mkdir(dirbuf.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0) throw CoreException(printfify("Error making new runtime directory: %s", strerror(errno)));#else if(!CreateDirectory(dirbuf.c_str(), NULL)) throw CoreException(printfify("Error making runtime new directory: %s", strerror(errno)));#endif } else { Flux::vector files = TextFile::DirectoryListing(dirbuf); for(Flux::vector::iterator it = files.begin(); it != files.end(); ++it) Delete(Flux::string(dirbuf + (*it)).c_str()); }}
开发者ID:Justasic,项目名称:Navn,代码行数:31,
示例5: SerializableNickAlias::NickAlias(const Anope::string &nickname, NickCore* nickcore) : Serializable("NickAlias"){ if (nickname.empty()) throw CoreException("Empty nick passed to NickAlias constructor"); else if (!nickcore) throw CoreException("Empty nickcore passed to NickAlias constructor"); this->time_registered = this->last_seen = Anope::CurTime; this->nick = nickname; this->nc = nickcore; nickcore->aliases->push_back(this); size_t old = NickAliasList->size(); (*NickAliasList)[this->nick] = this; if (old == NickAliasList->size()) Log(LOG_DEBUG) << "Duplicate nick " << nickname << " in nickalias table"; if (this->nc->o == NULL) { Oper *o = Oper::Find(this->nick); if (o == NULL) o = Oper::Find(this->nc->display); nickcore->o = o; if (this->nc->o != NULL) Log() << "Tied oper " << this->nc->display << " to type " << this->nc->o->ot->GetName(); }}
开发者ID:RanadeepPolavarapu,项目名称:IRCd,代码行数:27,
示例6: CoreExceptionstatic inline pthread_attr_t *GetAttr(){ static pthread_attr_t attr; if(pthread_attr_init(&attr)) throw CoreException("Error calling pthread_attr_init for Threads"); if(pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE)) throw CoreException("Unable to make threads joinable"); return &attr;}
开发者ID:Justasic,项目名称:TandemBicycle,代码行数:11,
示例7: CoreException/** * /fn Flux::string Log::TimeStamp() * /brief Returns a logging timestamp for use as log message prefixes * /return Generated human readable timestamp */Flux::string Log::TimeStamp(){ char tbuf[256]; time_t t; if(time(&t) < 0) throw CoreException("time() failed"); tm tm = *localtime(&t);#if HAVE_GETTIMEOFDAY if(protocoldebug) { char *s; struct timeval tv; gettimeofday(&tv, NULL); strftime(tbuf, sizeof(tbuf) - 1, "[%b %d %H:%M:%S", &tm); s = tbuf + strlen(tbuf); s += snprintf(s, sizeof(tbuf) - (s - tbuf), ".%06d", static_cast<int>(tv.tv_usec)); strftime(s, sizeof(tbuf) - (s - tbuf) - 1, " %Y]", &tm); } else#endif strftime(tbuf, sizeof(tbuf) - 1, "[%b %d %H:%M:%S %Y]", &tm); return Flux::Sanitize(tbuf);}
开发者ID:Justasic,项目名称:Navn,代码行数:32,
示例8: CoreExceptionvoid ViewDescriptor::LoadFromExtension(){ configElement->GetAttribute(WorkbenchRegistryConstants::ATT_ID, id); // Sanity check. std::string name; if ((configElement->GetAttribute(WorkbenchRegistryConstants::ATT_NAME, name) == false) || (RegistryReader::GetClassValue(configElement, WorkbenchRegistryConstants::ATT_CLASS) == "")) { throw CoreException( "Invalid extension (missing label or class name)", id); } std::string category; if (configElement->GetAttribute(WorkbenchRegistryConstants::TAG_CATEGORY, category)) { Poco::StringTokenizer stok(category, "/", Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM); // Parse the path tokens and store them for (Poco::StringTokenizer::Iterator iter = stok.begin(); iter != stok.end(); ++iter) { categoryPath.push_back(*iter); } }}
开发者ID:test-fd301,项目名称:MITK,代码行数:25,
示例9: switchsize_t cidr::hash::operator()(const cidr &s) const{ switch (s.addr.sa.sa_family) { case AF_INET: { unsigned int m = 0xFFFFFFFFU >> (32 - s.cidr_len); return s.addr.sa4.sin_addr.s_addr & m; } case AF_INET6: { size_t h = 0; for (unsigned i = 0; i < s.cidr_len / 8; ++i) h ^= (s.addr.sa6.sin6_addr.s6_addr[i] << ((i * 8) % sizeof(size_t))); int remaining = s.cidr_len % 8; unsigned char m = 0xFF << (8 - remaining); h ^= s.addr.sa6.sin6_addr.s6_addr[s.cidr_len / 8] & m; return h; } default: throw CoreException("Unknown AFTYPE for cidr"); }}
开发者ID:bonnedav,项目名称:anope,代码行数:27,
示例10: CoreExceptionvoid MySSLService::Init(Socket *s){ if (s->io != &NormalSocketIO) throw CoreException("Socket initializing SSL twice"); s->io = new SSLSocketIO();}
开发者ID:bonnedav,项目名称:anope,代码行数:7,
示例11: ConfValueEnumbool ServerConfig::CheckOnce(const char* tag){ int count = ConfValueEnum(this->config_data, tag); if (count > 1) { throw CoreException("You have more than one <"+std::string(tag)+"> tag, this is not permitted."); return false; } if (count < 1) { throw CoreException("You have not defined a <"+std::string(tag)+"> tag, this is required."); return false; } return true;}
开发者ID:rburchell,项目名称:hottpd,代码行数:16,
示例12: iterable IIterable::Pointer Expressions::GetAsIIterable(Object::Pointer var, Expression::Pointer expression) { IIterable::Pointer iterable(var.Cast<IIterable>()); if (!iterable.IsNull()) { return iterable; } else { IAdapterManager::Pointer manager= Platform::GetServiceRegistry().GetServiceById<IAdapterManager>("org.blueberry.service.adaptermanager"); Object::Pointer result; Poco::Any any(manager->GetAdapter(var, IIterable::GetStaticClassName())); if (!any.empty() && any.type() == typeid(Object::Pointer)) { result = Poco::AnyCast<Object::Pointer>(any); } if (result) { iterable = result.Cast<IIterable>(); return iterable; } if (manager->QueryAdapter(var->GetClassName(), IIterable::GetStaticClassName()) == IAdapterManager::NOT_LOADED) return IIterable::Pointer(); throw CoreException("The variable is not iterable", expression->ToString()); } }
开发者ID:test-fd301,项目名称:MITK,代码行数:30,
示例13: OnCTCP void OnCTCP(const Flux::string &source, const Flux::vector ¶ms) { Flux::string cmd = params.empty()?"":params[0]; Log(LOG_SILENT) << "Received CTCP " << Flux::Sanitize(cmd) << " from " << source; Log(LOG_TERMINAL) << "/033[22;31mReceived CTCP " << Flux::Sanitize(cmd) << " from " << source << Config->LogColor; if(cmd == "/001VERSION/001") { // for CTCP VERSION reply struct utsname uts; if(uname(&uts) < 0) throw CoreException("uname() Error"); ircproto->notice(source, "/001VERSION Navn-%s %s %s/001", VERSION_FULL, uts.sysname, uts.machine); } if(cmd == "/001TIME/001") { // for CTCP TIME reply ircproto->notice(source,"/001TIME %s/001", do_strftime(time(NULL), true).c_str()); } if(cmd == "/001SOURCE/001") { ircproto->notice(source, "/001SOURCE https://github.com/Justasic/Navn/001"); ircproto->notice(source, "/1SOURCE git://github.com/Justasic/Navn.git/1"); } if(cmd == "/001DCC") ircproto->notice(source, "I do not accept or support DCC connections."); }
开发者ID:DeathBlade,项目名称:Navn,代码行数:27,
示例14: streamvoid FileReader::Load(const std::string& filename){ // If the file is stored in the file cache then we used that version instead. std::string realName = ServerInstance->Config->Paths.PrependConfig(filename); ConfigFileCache::iterator it = ServerInstance->Config->Files.find(realName); if (it != ServerInstance->Config->Files.end()) { this->lines = it->second; } else { lines.clear(); std::ifstream stream(realName.c_str()); if (!stream.is_open()) throw CoreException(filename + " does not exist or is not readable!"); std::string line; while (std::getline(stream, line)) { lines.push_back(line); totalSize += line.size() + 2; } stream.close(); }}
开发者ID:AliSharifi,项目名称:inspircd,代码行数:27,
示例15: CoreExceptionvoid Server::SetSID(const Anope::string &nsid){ if (!this->sid.empty()) throw CoreException("Server already has an id?"); this->sid = nsid; Servers::ByID[nsid] = this;}
开发者ID:SaberUK,项目名称:anope,代码行数:7,
示例16: OnEncrypt EventReturn OnEncrypt(const Anope::string &src, Anope::string &dest) override { if (!md5) return EVENT_CONTINUE; Encryption::Context *context = md5->CreateContext(); context->Update(reinterpret_cast<const unsigned char *>(src.c_str()), src.length()); context->Finalize(); Encryption::Hash hash = context->GetFinalizedHash(); char digest[32], digest2[16]; memset(digest, 0, sizeof(digest)); if (hash.second > sizeof(digest)) throw CoreException("Hash too large"); memcpy(digest, hash.first, hash.second); for (int i = 0; i < 32; i += 2) digest2[i / 2] = XTOI(digest[i]) << 4 | XTOI(digest[i + 1]); Anope::string buf = "oldmd5:" + Anope::Hex(digest2, sizeof(digest2)); Log(LOG_DEBUG_2) << "(enc_old) hashed password from [" << src << "] to [" << buf << "]"; dest = buf; delete context; return EVENT_ALLOW; }
开发者ID:dream1986,项目名称:anope,代码行数:27,
示例17: CoreExceptionvoid InspIRCd::Restart(const std::string &reason){ /* SendError flushes each client's queue, * regardless of writeability state */ this->SendError(reason); /* Figure out our filename (if theyve renamed it, we're boned) */ std::string me; char** argv = Config->cmdline.argv;#ifdef _WIN32 char module[MAX_PATH]; if (GetModuleFileNameA(NULL, module, MAX_PATH)) me = module;#else me = argv[0];#endif this->Cleanup(); if (execv(me.c_str(), argv) == -1) { /* Will raise a SIGABRT if not trapped */ throw CoreException(std::string("Failed to execv()! error: ") + strerror(errno)); }}
开发者ID:H7-25,项目名称:inspircd,代码行数:28,
示例18: switch/** The equivalent of inet_pton * @param type AF_INET or AF_INET6 * @param address The address to place in the sockaddr structures * @param pport An option port to include in the sockaddr structures * @throws A socket exception if given invalid IPs */void sockaddrs::pton(int type, const Flux::string &address, int pport){ switch (type) { case AF_INET: int i = inet_pton(type, address.c_str(), &sa4.sin_addr); if (i == 0) throw SocketException("Invalid host"); else if (i <= -1) throw SocketException(printfify("Invalid host: %s", strerror(errno))); sa4.sin_family = type; sa4.sin_port = htons(pport); return; case AF_INET6: int i = inet_pton(type, address.c_str(), &sa6.sin6_addr); if (i == 0) throw SocketException("Invalid host"); else if (i <= -1) throw SocketException(printfify("Invalid host: %s", strerror(errno))); sa6.sin6_family = type; sa6.sin6_port = htons(pport); return; default: break; } throw CoreException("Invalid socket type");}
开发者ID:Justasic,项目名称:TandemBicycle,代码行数:34,
示例19: CoreException void Expressions::CheckCollection(Object::ConstPointer var, Expression::Pointer expression) { if (var.Cast<const ObjectVector<Object::Pointer> >()) return; throw CoreException("Expression variable is not of type ObjectVector", expression->ToString()); }
开发者ID:test-fd301,项目名称:MITK,代码行数:7,
示例20: CoreException/* NOTE: Before anyone asks why we're not using inet_pton for this, it is because inet_pton and friends do not return so much detail, * even in strerror(errno). They just return 'yes' or 'no' to an address without such detail as to whats WRONG with the address. * Because ircd users arent as technical as they used to be (;)) we are going to give more of a useful error message. */void ServerConfig::ValidateIP(const char* p, const std::string &tag, const std::string &val, bool wild){ int num_dots = 0; int num_seps = 0; int not_numbers = false; int not_hex = false; if (*p) { if (*p == '.') throw CoreException("The value of <"+tag+":"+val+"> is not an IP address"); for (const char* ptr = p; *ptr; ++ptr) { if (wild && (*ptr == '*' || *ptr == '?' || *ptr == '/')) continue; if (*ptr != ':' && *ptr != '.') { if (*ptr < '0' || *ptr > '9') not_numbers = true; if ((*ptr < '0' || *ptr > '9') && (toupper(*ptr) < 'A' || toupper(*ptr) > 'F')) not_hex = true; } switch (*ptr) { case ' ': throw CoreException("The value of <"+tag+":"+val+"> is not an IP address"); case '.': num_dots++; break; case ':': num_seps++; break; } } if (num_dots > 3) throw CoreException("The value of <"+tag+":"+val+"> is an IPv4 address with too many fields!"); if (num_seps > 8) throw CoreException("The value of <"+tag+":"+val+"> is an IPv6 address with too many fields!"); if (num_seps == 0 && num_dots < 3 && !wild) throw CoreException("The value of <"+tag+":"+val+"> looks to be a malformed IPv4 address"); if (num_seps == 0 && num_dots == 3 && not_numbers) throw CoreException("The value of <"+tag+":"+val+"> contains non-numeric characters in an IPv4 address"); if (num_seps != 0 && not_hex) throw CoreException("The value of <"+tag+":"+val+"> contains non-hexdecimal characters in an IPv6 address"); if (num_seps != 0 && num_dots != 3 && num_dots != 0 && !wild) throw CoreException("The value of <"+tag+":"+val+"> is a malformed IPv6 4in6 address"); }}
开发者ID:rburchell,项目名称:hottpd,代码行数:60,
示例21: ValidHoststatic void ValidHost(const std::string& p, const std::string& msg){ int num_dots = 0; if (p.empty() || p[0] == '.') throw CoreException("The value of "+msg+" is not a valid hostname"); for (unsigned int i=0;i < p.length();i++) { switch (p[i]) { case ' ': throw CoreException("The value of "+msg+" is not a valid hostname"); case '.': num_dots++; break; } } if (num_dots == 0) throw CoreException("The value of "+msg+" is not a valid hostname");}
开发者ID:bandicot,项目名称:inspircd,代码行数:19,
示例22: CoreExceptionvoid ServiceBot::GenerateUID(){ if (this->introduced) throw CoreException("Changing bot UID when it is introduced?"); if (!this->uid.empty()) UserListByUID.erase(this->uid); this->uid = IRCD->UID_Retrieve(); UserListByUID[this->uid] = this;}
开发者ID:bonnedav,项目名称:anope,代码行数:10,
示例23: CoreExceptionvoid User::SetNewNick(const Flux::string &newnick){ if(newnick.empty()) throw CoreException("User::SetNewNick() was called with empty arguement"); Log(LOG_TERMINAL) << "Setting new nickname: " << this->nick << " -> " << newnick; this->n->UserNickList.erase(this->nick); this->nick = newnick; this->n->UserNickList[this->nick] = this;}
开发者ID:Ephasic,项目名称:ANT,代码行数:10,
示例24: outer_parse bool outer_parse() { try { while (1) { int ch = next(true); switch (ch) { case EOF: // this is the one place where an EOF is not an error if (!mandatory_tag.empty()) throw CoreException("Mandatory tag /"" + mandatory_tag + "/" not found"); return true; case '#': comment(); break; case '<': dotag(); break; case ' ': case '/r': case '/t': case '/n': break; case 0xFE: case 0xFF: stack.errstr << "Do not save your files as UTF-16; use ASCII!/n"; default: throw CoreException("Syntax error - start of tag expected"); } } } catch (CoreException& err) { stack.errstr << err.GetReason() << " at " << current.str(); if (tag) stack.errstr << " (inside tag " << tag->tag << " at line " << tag->src_line << ")/n"; else stack.errstr << " (last tag was on line " << last_tag.line << ")/n"; } return false; }
开发者ID:KeiroD,项目名称:inspircd,代码行数:43,
注:本文中的CoreException函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ Core_EnableStepping函数代码示例 C++ CoreAssert函数代码示例 |