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


C++ t_string类代码示例

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


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

示例1: LookupHost

int CIpAddress::LookupHost( const t_string &x_sServer, unsigned int x_uPort, unsigned int x_uType )
{
#if defined( HTM_NOSOCKET2 )
	return 0;
#else
    // Lose old info
    Destroy();

    // Ensure we have a valid pointer
    if ( !x_sServer.length() )
        return 0;

	// First try to interpret as dot address
	unsigned long uAddr = inet_addr( x_sServer.c_str() );
	if ( INADDR_NONE == uAddr )
    {
        LPHOSTENT pHe = gethostbyname( x_sServer.c_str() );

        if ( !pHe )
            return 0;

        LPIN_ADDR pia = (LPIN_ADDR)*pHe->h_addr_list;
        if ( !pia )
            return 0;

        // Grab the address
        uAddr = *(DWORD*)&pia->S_un.S_addr;

    } // end if

    SetRawAddress( ntohl( uAddr ), x_uPort, x_uType );

    return 1;
#endif
}
开发者ID:summit4you,项目名称:QThybrid,代码行数:35,代码来源:sockets-windows.hpp

示例2: luaW_tofaivariant

variant luaW_tofaivariant(lua_State* L, int i) {
	switch(lua_type(L, i)) {
		case LUA_TBOOLEAN:
			return variant(lua_tointeger(L, i));
		case LUA_TNUMBER:
			return variant(lua_tonumber(L, i), variant::DECIMAL_VARIANT);
		case LUA_TSTRING:
			return variant(lua_tostring(L, i));
		case LUA_TTABLE:
			return variant(new lua_callable(L, i));
		case LUA_TUSERDATA:
			static t_string tstr;
			static vconfig vcfg = vconfig::unconstructed_vconfig();
			static map_location loc;
			if(luaW_totstring(L, i, tstr)) {
				return variant(tstr.str());
			} else if(luaW_tovconfig(L, i, vcfg)) {
				return variant(new config_callable(vcfg.get_parsed_config()));
			} else if(unit* u = luaW_tounit(L, i)) {
				return variant(new unit_callable(*u));
			} else if(luaW_tolocation(L, i, loc)) {
				return variant(new location_callable(loc));
			}
			break;
	}
	return variant();
}
开发者ID:Wedge009,项目名称:wesnoth,代码行数:27,代码来源:lua_formula_bridge.cpp

示例3: interpolate_variables_into_tstring

t_string interpolate_variables_into_tstring(const t_string &tstr, const variable_set& variables)
{
	if(!tstr.str().empty()) {
		std::string interp = utils::interpolate_variables_into_string(tstr.str(), variables);
		if(tstr.str() != interp) {
			return t_string(interp);
		}
	}
	return tstr;
}
开发者ID:AG-Dev,项目名称:wesnoth_ios,代码行数:10,代码来源:formula_string_utils.cpp

示例4:

/*
 * From the IRC log of 23.07.2010
 * 07:52 <silene> Upth: what did it break?
 * 07:53 <Upth> silene: since that revision, the windows executable crashes
 * immediately before loading the main menu
 * 07:54 <silene> what kind of crash?
 * 07:54 <Upth> assertion failed in the std::string library
 * 07:54 <Upth> then "fatal error"
 * 07:54 <Upth> and abnormal termination
 * 07:54 <silene> which assertion?
 * 07:55 <Upth> Expression: ("_Myptr + _Off <= (((_Mystring
 * *)this->_Mycont)->_Myptr() + ((_Mystring *)this->_Mycont)->_Mysize) &&
 * _Myptr + _Off >= ((_Mystring *)this->_Mycont)->_Myptr()", 0)
 * 07:56 <shadowmaster> ugly.
 * 07:57 <Upth> in the iterator += overload, called from the iterator +
 * overload, called from std::basic_string::end(), called from line 409 of
 * parser.cpp in write_key_val
 * 07:58 <Upth> err std::basic_string::end() is called from
 * t_string::walker::end(), which is called on line 409 of parser.cpp
 * 07:58 <silene> that doesn't make sense; as far as i can tell it's a compiler
 * bug
 * 07:58 <silene> which compiler is that so that the code is made conditional
 * on it?
 * 07:58 <Upth> MSVC9
 */
t_string_base::walker::walker(const t_string& string) :
	string_(string.get().value_),
	begin_(0),
	end_(string_.size()),
	textdomain_(),
	translatable_(false)
{
	if(string.get().translatable_) {
		update();
	}
}
开发者ID:CliffsDover,项目名称:wesnoth_ios,代码行数:36,代码来源:tstring.cpp

示例5: generate_pot

void generate_pot(std::set<std::string>& msgids, const t_string& tstr, const std::string& default_textdomain)
{
	if (tstr.str().empty()) {
		return;
	}
	std::vector<t_string_base::trans_str> trans = tstr.valuex();
	if (!trans.empty()) {
		if (trans[0].td.empty() || trans[0].td == default_textdomain) {
			msgids.insert(trans[0].str);
		}
	}
	return;
}
开发者ID:hyrio,项目名称:War-Of-Kingdom,代码行数:13,代码来源:help.cpp

示例6: SetDotAddress

// +++ Make IPv6 safe
int CIpAddress::SetDotAddress( const t_string &x_sDotAddress, unsigned int x_uPort, unsigned int x_uType )
{
    if ( !x_sDotAddress.length() )
        return 0;

    // Convert the dot address
    u_long ip = ntohl( inet_addr( x_sDotAddress.c_str() ) );
    if ( INADDR_NONE == ip )
        return 0;

    SetRawAddress( ip, x_uPort, x_uType );

    return 1;
}
开发者ID:AmberSandDan,项目名称:htmapp,代码行数:15,代码来源:sockets-posix.hpp

示例7: GetDomainName

CIpAddress::t_string CIpAddress::GetDomainName( const t_string &x_sServer )
{
	CIpAddress::t_string sRet;

	// Load netapi32.dll
	HMODULE hLib = LoadLibrary( tcT( "netapi32.dll" ) );
	if ( !hLib )
		return sRet;

	// Get function pointers
	pfn_NetApiBufferFree pNetApiBufferFree = (pfn_NetApiBufferFree)GetProcAddress( hLib, tcT( "NetApiBufferFree" ) );
	pfn_NetWkstaGetInfo pNetWkstaGetInfo = (pfn_NetWkstaGetInfo)GetProcAddress( hLib, tcT( "NetWkstaGetInfo" ) );

	// Attempt to read the domain name
	WKSTA_INFO_100 *pwi100 = 0;
	if ( pNetWkstaGetInfo
		 && !pNetWkstaGetInfo( x_sServer.length() ? (LPWSTR)tcStr2Wc( x_sServer ).c_str() : 0, 100, (LPBYTE*)&pwi100 ) )
		if ( pwi100 && pwi100->wki100_langroup )
			sRet = tcWc2Str( pwi100->wki100_langroup );

	// Free buffer
	if ( pNetApiBufferFree && pwi100 )
		pNetApiBufferFree( pwi100 );

	// Free library
	FreeLibrary( hLib );

	// Send the domain name along
	return sRet;
}
开发者ID:summit4you,项目名称:QThybrid,代码行数:30,代码来源:sockets-windows.hpp

示例8: LookupUri

int CIpAddress::LookupUri( const t_string &x_sUrl, unsigned int x_uPort, unsigned int x_uType )
{
    // Lose old info
    Destroy();

    // Ensure we have a valid pointer
    if ( !x_sUrl.length() )
        return 0;

    // Crack the url
    t_pb8 pbUri = parser::DecodeUri< t_pb8 >( x_sUrl );
    if ( !pbUri.size() )
        return 0;

    // Did we get a host name?
    if ( !pbUri[ "host" ].length() )
        return 0;

    // Get the port
    if ( !x_uPort )
        x_uPort = pbUri[ "port" ].ToLong();

    // Save the type
    m_uType = x_uType;

    return LookupHost( pbUri[ "host" ].str(), x_uPort );
}
开发者ID:AmberSandDan,项目名称:htmapp,代码行数:27,代码来源:sockets.cpp

示例9: CreateDirectory

bool DirUtil::CreateDirectory( const t_string &dirPath )
{
    if (!CreateParentDirectory(dirPath))
    {
        return false;
    }
    return ::CreateDirectory(dirPath.c_str(), NULL) == TRUE;
}
开发者ID:hanmengmeng,项目名称:hmlib,代码行数:8,代码来源:hm_dir.cpp

示例10: ZeroMemory

bool DirUtil::DeleteDirectory( const t_string &path )
{
#if 0
    SHFILEOPSTRUCT FileOp;
    ZeroMemory((void*)&FileOp, sizeof(SHFILEOPSTRUCT));

    t_string strFromPath = MakePathRegular(path);
    // this string must be double-null terminated
    strFromPath.append(1, _T('\0'));

    FileOp.fFlags = FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR | FOF_NOERRORUI | FOF_SILENT;
    FileOp.hNameMappings = NULL;
    FileOp.hwnd = NULL;
    FileOp.lpszProgressTitle = NULL;
    FileOp.pFrom = strFromPath.c_str();
    FileOp.pTo = NULL;
    FileOp.wFunc = FO_DELETE;

    return SHFileOperation(&FileOp) == 0;
#endif
    bool ret = true;
    std::vector<t_string> fileList;
    std::vector<t_string> dirList;
    if (EnumFiles(path, fileList))
    {
        for (size_t i = 0; i < fileList.size(); i++)
        {
            if (!DeleteFileIfExist(fileList.at(i)))
            {
                ret = false;
                break;
            }
        }
    }
    if (!ret)
    {
        return false;
    }

    if (EnumDirs(path, dirList))
    {
        for (size_t i = 0; i < dirList.size(); i++)
        {
            if (!DeleteDirectory(dirList.at(i)))
            {
                ret = false;
                break;
            }
        }
    }
    if (!ret)
    {
        return false;
    }
    return ::RemoveDirectory(path.c_str()) ? true : false;
}
开发者ID:hanmengmeng,项目名称:hmlib,代码行数:56,代码来源:hm_dir.cpp

示例11: DeleteFileIfExist

bool DirUtil::DeleteFileIfExist( const t_string &filePath )
{
    if (IsFileExist(filePath))
    {
        if (!::DeleteFile(filePath.c_str()))
        {
            _tchmod(filePath.c_str(), 0777);
            return ::DeleteFile(filePath.c_str()) ? true : false;
        }
        else
        {
            return true;
        }
    }
    else
    {
        return false;
    }
}
开发者ID:hanmengmeng,项目名称:hmlib,代码行数:19,代码来源:hm_dir.cpp

示例12: change_team

void team::change_team(const std::string& name, const t_string& user_name)
{
	info_.team_name = name;

	if(!user_name.empty()) {
		info_.user_team_name = user_name;
	} else {
		info_.user_team_name = name;
	}

	clear_caches();
}
开发者ID:fluffbeast,项目名称:wesnoth-old,代码行数:12,代码来源:team.cpp

示例13: write_key_val

void write_key_val(std::ostream &out, const std::string &key, const t_string &value, unsigned int level, std::string& textdomain)
{
	bool first = true;
	if (value.empty()) {
		out << std::string(level, '\t') << key << AttributeEquals
			<< AttributePrefix << AttributePostfix
			<< AttributeEndPostfix;;
		return;
	}

	for(t_string::walker w(value); !w.eos(); w.next()) {
		std::string part(w.begin(), w.end());

		if(w.translatable()) {
			if(w.textdomain() != textdomain) {
				out << TextdomainPrefix
					<< w.textdomain()
					<< TextdomainPostfix;
				textdomain = w.textdomain();
			}

			if(first) {
				out << std::string(level, '\t')
					<< key
					<< AttributeEquals;
			}

			out << TranslatableAttributePrefix
				<< escaped_string(part)
				<< AttributePostfix;

		} else {
			if(first) {
				out << std::string(level, '\t')
					<< key
					<< AttributeEquals;
			}

			out << AttributePrefix
				<< escaped_string(part)
				<< AttributePostfix;
		}

		if(w.last()) {
			out << AttributeEndPostfix;
		} else {
			out << AttributeContPostfix;
			out << std::string(level+1, '\t');
		}

		first = false;
	}
}
开发者ID:Alexander--,项目名称:Wesnoth-1.8-for-Android,代码行数:53,代码来源:parser.cpp

示例14: EnterCriticalSection

    DWORD Base::Write(const t_string & write_buffer, HANDLE pipe_handle, CRITICAL_SECTION & write_critical_section)
    {
        if (eState_ != STATE::started)
        {
            return ERROR_NOT_FOUND;
        }    

        EnterCriticalSection(&write_critical_section);

            DWORD cbWritten;

            BOOL bSuccess = WriteFile ( 
                                            pipe_handle,                                            // pipe handle 
                                            write_buffer.c_str(),                                   // message 
                                            write_buffer.length() * 
                                            sizeof(t_string::traits_type::char_type),               // message length 
                                            &cbWritten,                                             // bytes written 
                                            NULL                                                    // not overlapped 
                                        );

        LeaveCriticalSection(&write_critical_section);

        return bSuccess ? ERROR_SUCCESS : GetLastError();
    }
开发者ID:Andreyko,项目名称:NamedPipes,代码行数:24,代码来源:Base.cpp

示例15: EnterCriticalSection

    DWORD Client::Write(t_string write_buffer)
    {
        if (eState_ != STATE::started)
        {
            return ERROR_NOT_FOUND;
        }

        DWORD cbWritten;

        EnterCriticalSection(&csPipe_Write_);

            BOOL bSuccess = WriteFile ( 
                                            hPipe_,                                                 // pipe handle 
                                            write_buffer.c_str(),                                   // message 
                                            write_buffer.length() * 
                                            sizeof(t_string::traits_type::char_type),               // message length 
                                            &cbWritten,                                             // bytes written 
                                            NULL                                                    // not overlapped 
                                        );

        LeaveCriticalSection(&csPipe_Write_);

        return bSuccess ? ERROR_SUCCESS : GetLastError();
    }
开发者ID:Andreyko,项目名称:NamedPipes,代码行数:24,代码来源:Client.cpp


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