当前位置: 首页>>代码示例>>C++>>正文


C++ CoreException函数代码示例

本文整理汇总了C++中CoreException函数的典型用法代码示例。如果您正苦于以下问题:C++ CoreException函数的具体用法?C++ CoreException怎么用?C++ CoreException使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了CoreException函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CoreException

void 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,代码来源:configparser.cpp

示例2: socket

SocketThread::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,代码来源:threadengine_win32.cpp

示例3: CoreException

void 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,代码来源:raw_file.cpp

示例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,代码来源:modulehandler.cpp

示例5: Serializable

NickAlias::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,代码来源:nickalias.cpp

示例6: CoreException

static 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,代码来源:thread.cpp

示例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,代码来源:log.cpp

示例8: CoreException

void 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,代码来源:berryViewDescriptor.cpp

示例9: switch

size_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,代码来源:sockets.cpp

示例10: CoreException

void MySSLService::Init(Socket *s)
{
	if (s->io != &NormalSocketIO)
		throw CoreException("Socket initializing SSL twice");

	s->io = new SSLSocketIO();
}
开发者ID:bonnedav,项目名称:anope,代码行数:7,代码来源:ssl_openssl.cpp

示例11: ConfValueEnum

bool 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,代码来源:configreader.cpp

示例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,代码来源:berryExpressions.cpp

示例13: OnCTCP

  void OnCTCP(const Flux::string &source, const Flux::vector &params)
  {
    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,代码来源:m_ctcp.cpp

示例14: stream

void 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,代码来源:modules.cpp

示例15: CoreException

void 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,代码来源:servers.cpp


注:本文中的CoreException函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。