• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ flux::string类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: search

/**
 * \fn Flux::string search(Flux::string s, Flux::string command)
 * \brief generates search links for url's
 * This is what generates the search links.
 */
Flux::string search(const Flux::string &text, const Flux::string &command)
{
	Flux::string searchstring = text.url_str();

	if(searchstring.empty())
		return "Empty searchstring.";
	else
	{
		if(command.equals_ci("google"))
			return "http://www.google.com/search?q=" + searchstring;
		else if(command.equals_ci("youtube"))
			return "http://www.youtube.com/results?search_query=" + searchstring;
		else if(command.equals_ci("tpb"))
			return "http://thepiratebay.org/search/" + searchstring;
		else if(command.equals_ci("define"))
			return "http://dictionary.reference.com/browse/" + searchstring;
		else if(command.equals_ci("urban"))
			return "http://www.urbandictionary.com/define.php?term=" + searchstring;
		else if(command.equals_ci("movie"))
			return "www.letmewatchthis.ch/index.php?search_keywords=" + searchstring;
		else if(command.equals_ci("lmgtfy"))
			return "http://lmgtfy.com/?q=" + searchstring;
		else
			return "http://www.google.com/search?q=" + searchstring;
	}
}
开发者ID:Justasic,项目名称:Navn,代码行数:31,代码来源:m_searcher.cpp


示例2: SanitizeRuntime

/**
 * \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


示例3: SocketException

cidr::cidr(const Flux::string &ip)
{
	if (ip.find_first_not_of("01234567890:./") != Flux::string::npos)
		throw SocketException("Invalid IP");

	bool ipv6 = ip.search(':');
	size_t sl = ip.find_last_of('/');
	if (sl == Flux::string::npos)
	{
		this->cidr_ip = ip;
		this->cidr_len = ipv6 ? 128 : 32;
		this->addr.pton(ipv6 ? AF_INET6 : AF_INET, ip);
	}
	else
	{
		Flux::string real_ip = ip.substr(0, sl);
		Flux::string cidr_range = ip.substr(sl + 1);
		if (!cidr_range.is_pos_number_only())
			throw SocketException("Invalid CIDR range");

		this->cidr_ip = real_ip;
		this->cidr_len = value_cast<unsigned int>(cidr_range);
		this->addr.pton(ipv6 ? AF_INET6 : AF_INET, real_ip);
	}
}
开发者ID:Justasic,项目名称:TandemBicycle,代码行数:25,代码来源:Socket.cpp


示例4: pton

/** 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,代码来源:Socket.cpp


示例5: Run

	void Run(CommandSource &source, const Flux::vector &params)
	{
		Flux::string chan = params[1];
		User *u = source.u;

		if(!u->IsOwner())
		{
			source.Reply(ACCESS_DENIED);
			Log(u) << "attempted to make bot part " << chan;
			return;
		}

		if(!IsValidChannel(chan))
			source.Reply(CHANNEL_X_INVALID, chan.c_str());
		else
		{
			Channel *c = findchannel(chan);

			if(c)
				c->SendPart();
			else
				source.Reply("I am not in channel \2%s\2", chan.c_str());

			Log(u) << "made the bot part " << chan;
		}
	}
开发者ID:Justasic,项目名称:Navn,代码行数:26,代码来源:m_join.cpp


示例6: DeleteModule

/**
 * \fn bool ModuleHandler::DeleteModule(Module *m)
 * \brief Delete the Module from Module lists and unload it from navn completely
 * \param Module the Module to be removed
 */
bool ModuleHandler::DeleteModule(Module *m)
{
	SET_SEGV_LOCATION();

	if(!m || !m->handle)
		return false;

	void *handle = m->handle;
	Flux::string filepath = m->filepath;

	dlerror();
	void (*df)(Module *) = function_cast<void ( *)(Module *)>(dlsym(m->handle, "ModunInit"));
	const char *err = dlerror();

	if(!df && err && *err)
	{
		Log(LOG_WARN) << "No destroy function found for " << m->name << ", chancing delete...";
		delete m; /* we just have to chance they haven't overwrote the delete operator then... */
	}
	else
		df(m); /* Let the Module delete it self, just in case */


	if(handle)
		if(dlclose(handle))
			Log() << "[" << m->name << ".so] " << dlerror();

	if(!filepath.empty())
		Delete(filepath.c_str());

	return true;
}
开发者ID:Justasic,项目名称:Navn,代码行数:37,代码来源:modulehandler.cpp


示例7: OnChannelOp

	void OnChannelOp(User *u, Channel *c, const Flux::string &mode, const Flux::string &nick)
	{
		if(!u || !c)
			return;

		if(c->name != Config->LogChannel)
			return;

		CLog("*** %s sets mode %s %s %s", u->nick.c_str(), c->name.c_str(), mode.c_str(), nick.c_str());
	}
开发者ID:Justasic,项目名称:Navn,代码行数:10,代码来源:channel_logger.cpp


示例8: __ConcatenateString

// Private Function! used by Flux::string.implode()
Flux::string __ConcatenateString(const Flux::vector &str, char delim = ' ')
{
	Flux::string temp;
	for (unsigned i = 0; i < str.size(); ++i)
	{
		if(!temp.empty())
		temp += delim;
		temp += str[i];
	}
	
	return temp;
}
开发者ID:Justasic,项目名称:TandemBicycle,代码行数:13,代码来源:Sepstream.cpp


示例9: NoTermColor

/**
 * \fn Flux::string NoTermColor(const Flux::string &ret)
 * \brief Strip all *nix terminal style colors
 * \param buffer Buffer to strip
 */
Flux::string NoTermColor(const Flux::string &ret)
{
	Flux::string str;
	bool in_term_color = false;

	for(unsigned i = 0; i < ret.length(); ++i)
	{
		char c = ret[i];

		if(in_term_color)
		{
			if(c == 'm')
				in_term_color = false;

			continue;
		}

		if(c == '\033')
		{
			in_term_color = true;
			continue;
		}

		if(!in_term_color)
			str += c;
	}

	return str;
}
开发者ID:Justasic,项目名称:Navn,代码行数:34,代码来源:log.cpp


示例10:

cidr::cidr(const Flux::string &ip, unsigned char len)
{
	bool ipv6 = ip.search(':');
	this->addr.pton(ipv6 ? AF_INET6 : AF_INET, ip);
	this->cidr_ip = ip;
	this->cidr_len = len;
}
开发者ID:Justasic,项目名称:TandemBicycle,代码行数:7,代码来源:Socket.cpp


示例11: SetNewNick

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


示例12: OnPart

	void OnPart(User *u, Channel *c, const Flux::string &reason)
	{
		if(!u || !c)
			return;

		if(c->name != Config->LogChannel)
			return;

		CLog("*** %s has parted %s (%s)", u->nick.c_str(), c->name.c_str(), reason.c_str());
	}
开发者ID:Justasic,项目名称:Navn,代码行数:10,代码来源:channel_logger.cpp


示例13: OnNoticeChannel

	void OnNoticeChannel(User *u, Channel *c, const Flux::vector &params)
	{
		if(!u || !c)
			return;

		if(c->name != Config->LogChannel)
			return;

		Flux::string msg;

		for(unsigned i = 0; i < params.size(); ++i)
			msg += params[i] + ' ';

		msg.trim();
		Flux::string nolog = params.size() == 2 ? params[1] : "";

		if(nolog != "#nl" && u)
			CLog("-Notice- %s: %s", u->nick.c_str(), Flux::Sanitize(msg).c_str());
	}
开发者ID:Justasic,项目名称:Navn,代码行数:19,代码来源:channel_logger.cpp


示例14: uname

int uname(struct utsname *info)
{
	// get the system information.
	OSVERSIONINFOEX wininfo;
	SYSTEM_INFO si;
	Flux::string WindowsVer = GetWindowsVersion();
	Flux::string cputype;
	char hostname[256] = "\0";
	ZeroMemory(&wininfo, sizeof(OSVERSIONINFOEX));
	ZeroMemory(&si, sizeof(SYSTEM_INFO));
	wininfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);

	if(!GetVersionEx(reinterpret_cast<OSVERSIONINFO *>(&wininfo)))
		return -1;

	GetSystemInfo(&si);

	// Get the hostname
	if(gethostname(hostname, sizeof(hostname)) == SOCKET_ERROR)
		return -1;

	if(si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
		cputype = "64-bit";
	else if(si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL)
		cputype = "32-bit";
	else if(si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64)
		cputype = "Itanium 64-bit";

	// Fill the utsname struct with the windows system info
	strcpy(info->sysname, "Windows");
	strcpy(info->nodename, hostname);
	strcpy(info->release, WindowsVer.c_str());
	strcpy(info->version, printfify("%ld.%ld-%ld", wininfo.dwMajorVersion, wininfo.dwMinorVersion, wininfo.dwBuildNumber).c_str());
	strcpy(info->machine, cputype.c_str());

	// Null-Terminate
	info->nodename[strlen(info->nodename) - 1] = '\0';
	info->sysname[strlen(info->sysname) - 1] = '\0';
	info->release[strlen(info->sysname) - 1] = '\0';
	info->version[strlen(info->version) - 1] = '\0';
	info->machine[strlen(info->machine) - 1] = '\0';
}
开发者ID:Justasic,项目名称:Navn,代码行数:42,代码来源:uname.cpp


示例15: CoreException

User::User(Network *net, const Flux::string &snick, const Flux::string &sident, const Flux::string &shost, const Flux::string &srealname, const Flux::string &sserver) : nick(snick), host(shost), realname(srealname), ident(sident), fullhost(snick+"!"+sident+"@"+shost), server(sserver), n(net)
{
    /* check to see if a empty string was passed into the constructor */
    if(snick.empty() || sident.empty() || shost.empty())
	throw CoreException("Bad args sent to User constructor");
    if(!net)
	throw CoreException("User created with no network??");


    this->n->UserNickList[snick] = this;
    CUserMap[this] = std::vector<Channel*>();

    Log(LOG_RAWIO) << "New user! " << this->nick << '!' << this->ident << '@' << this->host << (this->realname.empty()?"":" :"+this->realname);

    ++usercnt;
    if(usercnt > maxusercnt)
    {
	maxusercnt = usercnt;
	Log(LOG_TERMINAL) << "New maximum user count: " << maxusercnt;
    }
}
开发者ID:Ephasic,项目名称:ANT,代码行数:21,代码来源:user.cpp


示例16: Read

/**
 * \fn bool SocketIO::Read(const Flux::string &buf) const
 * \brief Read from a socket for the IRC processor
 * \param buffer Raw socket buffer
 */
bool SocketIO::Read(const Flux::string &buf) const
{
  if(buf.search_ci("ERROR :Closing link:"))
  {
    FOREACH_MOD(I_OnSocketError, OnSocketError(buf));
    return false;
  }
  
  Log(LOG_RAWIO) << "Received: " << Flux::Sanitize(buf);
  process(buf); /* Process the buffer for navn */
  return true;
}
开发者ID:DeathBlade,项目名称:Navn,代码行数:17,代码来源:Socket.cpp


示例17: Brain

 void Brain(User *u, Flux::string q)
 {
   if(!(cdt.requested >= 30))
   {
     cdt.requested++;
     Log(LOG_TERMINAL) << "Requests: " << cdt.requested;
     Sanitize(q);
     Flux::string str = "python brain.py "+q;
     Flux::string information = execute(str.c_str());
     information.trim();
     if (information.search_ci("For search options, see Help:Searching")) u->SendMessage(RandomOops());
     else if (information.search_ci("may refer to:") ||  information.search_ci("reasons this message may be displayed:") ) u->SendMessage(RandomAmb());
     else u->SendMessage(information.strip());
   }else
     u->SendMessage(TooManyRequests());
 }
开发者ID:DeathBlade,项目名称:Navn,代码行数:16,代码来源:m_encyclopedia.cpp


示例18: OnPrivmsgChannel

	void OnPrivmsgChannel(User *u, Channel *c, const Flux::vector &params)
	{
		Flux::string nolog = params.size() == 2 ? params[1] : "";

		if(!u || !c)
			return;

		if(c->name != Config->LogChannel)
			return;

		Flux::string msg = ConcatinateVector(params);

		if(nolog != "#nl" && u)
		{
			if(nolog == "\001ACTION")
			{
				msg = msg.erase(0, 8);
				CLog("*** %s %s", u->nick.c_str(), Flux::Sanitize(msg).c_str());
			}
			else
				CLog("<%s> %s", u->nick.c_str(), msg.c_str());
		}
	}
开发者ID:Justasic,项目名称:Navn,代码行数:23,代码来源:channel_logger.cpp


示例19: Run

  void Run(CommandSource &source, const std::vector<Flux::string> &params)
  {
    Flux::string cmds;
    if(!params.empty())
    {
      Command *c = FindCommand(params[1], C_CHANNEL);
      if(c && !c->OnHelp(source, ""))
	source.Reply("No help available for \2%s\2", params[1].c_str());
      else if(!c)
	source.Reply("No help available for \2%s\2", params[1].c_str());
      Log(source.u) << "used help command on " << params[1];
    }
    else
    {
      for(auto val : ChanCommandMap) //As you can see C++11 is MUCH better than C++98
	cmds += val.second->name+" ";
      cmds.trim();
      cmds.tolower();
      source.u->SendMessage("Local %s Commands:", source.c->name.c_str());
      source.u->SendMessage(cmds);
      Log(source.u) << "used help command";
    }
  }
开发者ID:Ephasic,项目名称:ANT,代码行数:23,代码来源:help.cpp


示例20: Sanitize

 void Sanitize(Flux::string &victim)
 {
   victim = victim.replace_all_cs("&","");
   victim = victim.replace_all_cs("|","");
   victim = victim.replace_all_cs(">","");
   victim = victim.replace_all_cs("<","");
   victim = victim.replace_all_cs("!","");
   victim = victim.replace_all_cs("(","");
   victim = victim.replace_all_cs(")","");
   victim = victim.replace_all_cs("*","");
   victim = victim.replace_all_cs("{","");
   victim = victim.replace_all_cs("}","");
   victim = victim.replace_all_cs("`","");
   victim = victim.replace_all_cs("\"","");
   victim = victim.replace_all_cs("\'","");
   victim = victim.replace_all_cs(".","");
   victim = victim.replace_all_cs("?","");
 }
开发者ID:DeathBlade,项目名称:Navn,代码行数:18,代码来源:m_encyclopedia.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ flycapture2::Error类代码示例发布时间:2022-05-31
下一篇:
C++ floatvectorimagetype::Pointer类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap