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

C++ reference类代码示例

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

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



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

示例1: same_date

int same_date(const reference &r1, const reference &r2)
{
  const char *e1;
  const char *s1 = r1.get_date(&e1);
  const char *e2;
  const char *s2 = r2.get_date(&e2);
  if (s1 == 0)
    return s2 == 0;
  else if (s2 == 0)
    return 0;
  else if (e1 - s1 != e2 - s2)
    return 0;
  else
    return memcmp(s1, s2, e1 - s1) == 0;
}
开发者ID:att,项目名称:uwin,代码行数:15,代码来源:ref.cpp


示例2: address

        // Returns the actual address of x even in presence of overloaded
        // operator&
        pointer address(reference x) const noexcept
        {
#if defined(HPX_COMPUTE_DEVICE_CODE)
            return &x;
#else
            return pointer(x.device_ptr(), target_);
#endif
        }
开发者ID:ShmuelLevine,项目名称:hpx,代码行数:10,代码来源:allocator.hpp


示例3: insert

		// R, this->P.
		void insert(reference R)
		{
			R.destroy();

			R.Prev = this->P->Prev;
			R.Next = this->P;

			R.Prev->Next = R.Next->Prev = &R;
		}
开发者ID:BackupTheBerlios,项目名称:cbear-svn,代码行数:10,代码来源:list.hpp


示例4: InsertAnimation

bool GfxAnimationSet::InsertAnimation(const reference<GfxAnimation>& animation)
{
    assert(animation);
    if (animation)
    {
        auto emplaceResult = m_AnimationsMap.emplace(animation->GetAnimationName(), animation);
        return emplaceResult.second;
    }
    return false;
}
开发者ID:codenamecpp,项目名称:RTS2,代码行数:10,代码来源:GfxAnimation.cpp


示例5: same_year

int same_year(const reference &r1, const reference &r2)
{
  const char *ye1;
  const char *ys1 = r1.get_year(&ye1);
  const char *ye2;
  const char *ys2 = r2.get_year(&ye2);
  if (ys1 == 0) {
    if (ys2 == 0)
      return same_date(r1, r2);
    else
      return 0;
  }
  else if (ys2 == 0)
    return 0;
  else if (ye1 - ys1 != ye2 - ys2)
    return 0;
  else
    return memcmp(ys1, ys2, ye1 - ys1) == 0;
}
开发者ID:att,项目名称:uwin,代码行数:19,代码来源:ref.cpp


示例6: dotag

	void dotag()
	{
		last_tag = current;
		std::string name;
		nextword(name);

		int spc = next();
		if (spc == '>')
			unget(spc);
		else if (!isspace(spc))
			throw CoreException("Invalid character in tag name");

		if (name.empty())
			throw CoreException("Empty tag name");

		ConfigItems* items;
		tag = ConfigTag::create(name, current.filename, current.line, items);

		while (kv(items))
		{
			// Do nothing here (silences a GCC warning).
		}

		if (name == mandatory_tag)
		{
			// Found the mandatory tag
			mandatory_tag.clear();
		}

		if (name == "include")
		{
			stack.DoInclude(tag, flags);
		}
		else if (name == "files")
		{
			for(ConfigItems::iterator i = items->begin(); i != items->end(); i++)
			{
				stack.DoReadFile(i->first, i->second, flags, false);
			}
		}
		else if (name == "execfiles")
		{
			for(ConfigItems::iterator i = items->begin(); i != items->end(); i++)
			{
				stack.DoReadFile(i->first, i->second, flags, true);
			}
		}
		else if (name == "define")
		{
			if (flags & FLAG_USE_COMPAT)
				throw CoreException("<define> tags may only be used in XML-style config (add <config format=\"xml\">)");
			std::string varname = tag->getString("name");
			std::string value = tag->getString("value");
			if (varname.empty())
				throw CoreException("Variable definition must include variable name");
			stack.vars[varname] = value;
		}
		else if (name == "config")
		{
			std::string format = tag->getString("format");
			if (format == "xml")
				flags &= ~FLAG_USE_COMPAT;
			else if (format == "compat")
				flags |= FLAG_USE_COMPAT;
			else if (!format.empty())
				throw CoreException("Unknown configuration format " + format);
		}
		else
		{
			stack.output.insert(std::make_pair(name, tag));
		}
		// this is not a leak; reference<> takes care of the delete
		tag = NULL;
	}
开发者ID:KeiroD,项目名称:inspircd,代码行数:74,代码来源:configparser.cpp


示例7: push

inline void push(lua_State*, reference& ref) {
    ref.push();
}
开发者ID:DominikMS,项目名称:sol,代码行数:3,代码来源:stack.hpp


示例8: value_consumer

 value_consumer(reference x)
     : list_(x)
     , pos_(x.begin())
     , end_(x.end())
 {}
开发者ID:peplopez,项目名称:El-Rayo-de-Zeus,代码行数:5,代码来源:values.hpp


示例9: reference

 reference(const reference& o) noexcept {
     L = o.L;
     ref = o.copy();
 }
开发者ID:Dogboss08,项目名称:IntWars,代码行数:4,代码来源:reference.hpp


示例10: RenderString

void StringPrinter::RenderString(const reference<BitmapFont>& bitmapFont, 
    const char* szPrintableString, int maxLength, 
        int positionX, 
        int positionY, 
        int clipWidth, 
        int clipHeight, eUiTextColor color)
{
    assert(bitmapFont);
    if (!bitmapFont || !szPrintableString || maxLength == 0 || clipWidth == 0 || clipHeight == 0)
    {
        return;
    }
    
    // setup palette
    if (mCurrentTextColor != color)
    {
        mCurrentTextColor = color;
        GfxRenderDevice::Instance().SetPaletteEntries(gUiTextColorsRGB[mCurrentTextColor], NUM_UI_TEXT_COLOR_ENTRIES, 0, GFX_PALETTE_UI);
    }

    const BitmapFontDescription& bmpf = bitmapFont->GetFontDescription();

    // tiles buffer
    GfxTile batchQuads[256];

    // process characters
    for (int iquad = 0, currentBoxWidth = 0, currentBoxHeight = 0, ichar = 0;; ++ichar)
    {
        if (szPrintableString[ichar] == 0 || (maxLength > 0 && ichar == maxLength))
        {
            if (iquad > 0)
            {
                mRenderDevice.RenderTilesBatch(bmpf.fontTexture, batchQuads, iquad);
            }
            break;
        }

        const BitmapFontCharacter& bmpc = bitmapFont->GetCharacter(szPrintableString[ichar]);
        if (bmpc.height == 0 || bmpc.width == 0)
        {
            continue;
        }

        bool shouldEnd = 
            ((clipWidth > 0) && (currentBoxWidth + bmpc.width + bmpc.xadvance > clipWidth)) ||
            ((clipHeight > 0) && (currentBoxHeight + bmpc.height > clipHeight));

        if (shouldEnd)
        {
            maxLength = ichar + 1;
            continue;
        }

        currentBoxWidth += bmpc.width + bmpc.xadvance;
        currentBoxHeight += bmpc.height;
        batchQuads[iquad].destination = { positionX, positionY, 128 };
        batchQuads[iquad].rcSource = { bmpc.xoffset, bmpc.yoffset, bmpc.width, bmpc.height };
        batchQuads[iquad].params = {};
        batchQuads[iquad].params.paletteIndex = GFX_PALETTE_UI;
        positionX += bmpc.width + bmpc.xadvance;

        if (++iquad == sizeof(batchQuads))
        {
            mRenderDevice.RenderTilesBatch(bmpf.fontTexture, batchQuads, iquad);
            iquad = 0;
        }
    }    
}
开发者ID:codenamecpp,项目名称:RTS2,代码行数:68,代码来源:StringPrinter.cpp


示例11: setDefaultHandler

 static reference<const WarningHandler> setDefaultHandler(const WarningHandler& handler)
 {
    reference<const WarningHandler> tmp = _defaultHandler;
    _defaultHandler.assign(handler);
    return tmp;
 }
开发者ID:adityapathak89,项目名称:scetlib,代码行数:6,代码来源:warning_impl.hpp


示例12: ModeHandler

	CustomPrefixMode(Module* parent, ConfigTag* Tag)
		: ModeHandler(parent, Tag->getString("name"), 0, PARAM_ALWAYS, MODETYPE_CHANNEL), tag(Tag)
	{
		list = true;
		m_paramtype = TR_NICK;
		std::string v = tag->getString("prefix");
		prefix = v.c_str()[0];
		v = tag->getString("letter");
		mode = v.c_str()[0];
		rank = tag->getInt("rank");
		levelrequired = tag->getInt("ranktoset", rank);
		depriv = tag->getBool("depriv", true);
	}
开发者ID:H7-25,项目名称:inspircd,代码行数:13,代码来源:m_customprefix.cpp


示例13: PrefixMode

	CustomPrefixMode(Module* parent, const std::string& Name, char Letter, char Prefix, ConfigTag* Tag)
		: PrefixMode(parent, Name, Letter, 0, Prefix)
		, tag(Tag)
	{
		unsigned long rank = tag->getUInt("rank", 0, 0, UINT_MAX);
		unsigned long setrank = tag->getUInt("ranktoset", prefixrank, rank, UINT_MAX);
		unsigned long unsetrank = tag->getUInt("ranktounset", setrank, setrank, UINT_MAX);
		bool depriv = tag->getBool("depriv", true);
		this->Update(rank, setrank, unsetrank, depriv);

		ServerInstance->Logs.Log(MODNAME, LOG_DEBUG, "Created the %s prefix: letter=%c prefix=%c rank=%u ranktoset=%u ranktounset=%i depriv=%d",
			name.c_str(), GetModeChar(), GetPrefix(), GetPrefixRank(), GetLevelRequired(true), GetLevelRequired(false), CanSelfRemove());
	}
开发者ID:Adam-,项目名称:inspircd,代码行数:13,代码来源:m_customprefix.cpp


示例14: InitSession

	void InitSession(StreamSocket* user, bool me_server)
	{
		gnutls_init(&sess, me_server ? GNUTLS_SERVER : GNUTLS_CLIENT);

		profile->SetupSession(sess);
		gnutls_transport_set_ptr(sess, reinterpret_cast<gnutls_transport_ptr_t>(user));
		gnutls_transport_set_push_function(sess, gnutls_push_wrapper);
		gnutls_transport_set_pull_function(sess, gnutls_pull_wrapper);

		if (me_server)
			gnutls_certificate_server_set_request(sess, GNUTLS_CERT_REQUEST); // Request client certificate if any.
	}
开发者ID:NikosPapakonstantinou,项目名称:inspircd,代码行数:12,代码来源:m_ssl_gnutls.cpp


示例15: GetDSN

	std::string GetDSN()
	{
		std::ostringstream conninfo("connect_timeout = '5'");
		std::string item;

		if (conf->readString("host", item))
			conninfo << " host = '" << item << "'";

		if (conf->readString("port", item))
			conninfo << " port = '" << item << "'";

		if (conf->readString("name", item))
			conninfo << " dbname = '" << item << "'";

		if (conf->readString("user", item))
			conninfo << " user = '" << item << "'";

		if (conf->readString("pass", item))
			conninfo << " password = '" << item << "'";

		if (conf->getBool("ssl"))
			conninfo << " sslmode = 'require'";
		else
			conninfo << " sslmode = 'disable'";

		return conninfo.str();
	}
开发者ID:AliSharifi,项目名称:inspircd,代码行数:27,代码来源:m_pgsql.cpp


示例16: VerifyCertificate

	void VerifyCertificate()
	{
		X509* cert;
		ssl_cert* certinfo = new ssl_cert;
		this->certificate = certinfo;
		unsigned int n;
		unsigned char md[EVP_MAX_MD_SIZE];

		cert = SSL_get_peer_certificate(sess);

		if (!cert)
		{
			certinfo->error = "Could not get peer certificate: "+std::string(get_error());
			return;
		}

		certinfo->invalid = (SSL_get_verify_result(sess) != X509_V_OK);

		if (!SelfSigned)
		{
			certinfo->unknownsigner = false;
			certinfo->trusted = true;
		}
		else
		{
			certinfo->unknownsigner = true;
			certinfo->trusted = false;
		}

		char buf[512];
		X509_NAME_oneline(X509_get_subject_name(cert), buf, sizeof(buf));
		certinfo->dn = buf;
		X509_NAME_oneline(X509_get_issuer_name(cert), buf, sizeof(buf));
		certinfo->issuer = buf;

		if (!X509_digest(cert, profile->GetDigest(), md, &n))
		{
			certinfo->error = "Out of memory generating fingerprint";
		}
		else
		{
			certinfo->fingerprint = BinToHex(md, n);
		}

		if ((ASN1_UTCTIME_cmp_time_t(X509_get_notAfter(cert), ServerInstance->Time()) == -1) || (ASN1_UTCTIME_cmp_time_t(X509_get_notBefore(cert), ServerInstance->Time()) == 0))
		{
			certinfo->error = "Not activated, or expired certificate";
		}

		X509_free(cert);
	}
开发者ID:FrostyCoolSlug,项目名称:inspircd,代码行数:51,代码来源:m_ssl_openssl.cpp


示例17: VerifyCertificate

	void VerifyCertificate()
	{
		unsigned int certstatus;
		const gnutls_datum_t* cert_list;
		int ret;
		unsigned int cert_list_size;
		gnutls_x509_crt_t cert;
		char str[512];
		unsigned char digest[512];
		size_t digest_size = sizeof(digest);
		size_t name_size = sizeof(str);
		ssl_cert* certinfo = new ssl_cert;
		this->certificate = certinfo;

		/* This verification function uses the trusted CAs in the credentials
		 * structure. So you must have installed one or more CA certificates.
		 */
		ret = gnutls_certificate_verify_peers2(this->sess, &certstatus);

		if (ret < 0)
		{
			certinfo->error = std::string(gnutls_strerror(ret));
			return;
		}

		certinfo->invalid = (certstatus & GNUTLS_CERT_INVALID);
		certinfo->unknownsigner = (certstatus & GNUTLS_CERT_SIGNER_NOT_FOUND);
		certinfo->revoked = (certstatus & GNUTLS_CERT_REVOKED);
		certinfo->trusted = !(certstatus & GNUTLS_CERT_SIGNER_NOT_CA);

		/* Up to here the process is the same for X.509 certificates and
		 * OpenPGP keys. From now on X.509 certificates are assumed. This can
		 * be easily extended to work with openpgp keys as well.
		 */
		if (gnutls_certificate_type_get(this->sess) != GNUTLS_CRT_X509)
		{
			certinfo->error = "No X509 keys sent";
			return;
		}

		ret = gnutls_x509_crt_init(&cert);
		if (ret < 0)
		{
			certinfo->error = gnutls_strerror(ret);
			return;
		}

		cert_list_size = 0;
		cert_list = gnutls_certificate_get_peers(this->sess, &cert_list_size);
		if (cert_list == NULL)
		{
			certinfo->error = "No certificate was found";
			goto info_done_dealloc;
		}

		/* This is not a real world example, since we only check the first
		 * certificate in the given chain.
		 */

		ret = gnutls_x509_crt_import(cert, &cert_list[0], GNUTLS_X509_FMT_DER);
		if (ret < 0)
		{
			certinfo->error = gnutls_strerror(ret);
			goto info_done_dealloc;
		}

		if (gnutls_x509_crt_get_dn(cert, str, &name_size) == 0)
		{
			std::string& dn = certinfo->dn;
			dn = str;
			// Make sure there are no chars in the string that we consider invalid
			if (dn.find_first_of("\r\n") != std::string::npos)
				dn.clear();
		}

		name_size = sizeof(str);
		if (gnutls_x509_crt_get_issuer_dn(cert, str, &name_size) == 0)
		{
			std::string& issuer = certinfo->issuer;
			issuer = str;
			if (issuer.find_first_of("\r\n") != std::string::npos)
				issuer.clear();
		}

		if ((ret = gnutls_x509_crt_get_fingerprint(cert, profile->GetHash(), digest, &digest_size)) < 0)
		{
			certinfo->error = gnutls_strerror(ret);
		}
		else
		{
			certinfo->fingerprint = BinToHex(digest, digest_size);
		}

		/* Beware here we do not check for errors.
		 */
		if ((gnutls_x509_crt_get_expiration_time(cert) < ServerInstance->Time()) || (gnutls_x509_crt_get_activation_time(cert) > ServerInstance->Time()))
		{
			certinfo->error = "Not activated, or expired certificate";
		}

//.........这里部分代码省略.........
开发者ID:NikosPapakonstantinou,项目名称:inspircd,代码行数:101,代码来源:m_ssl_gnutls.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ reference_wrapper类代码示例发布时间:2022-05-31
下一篇:
C++ ref_ptr类代码示例发布时间: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