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


C++ OTString::Set方法代码示例

本文整理汇总了C++中OTString::Set方法的典型用法代码示例。如果您正苦于以下问题:C++ OTString::Set方法的具体用法?C++ OTString::Set怎么用?C++ OTString::Set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OTString的用法示例。


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

示例1: TranslateAccountTypeToString

void TranslateAccountTypeToString(OTAccount::AccountType theType, OTString & strAcctType)
{
	switch (theType)
	{
		case OTAccount::simple:
			strAcctType.Set("simple");
			break;
		case OTAccount::issuer:
			strAcctType.Set("issuer");
			break;
		case OTAccount::basket:
			strAcctType.Set("basket");
			break;
		case OTAccount::basketsub:
			strAcctType.Set("basketsub");
			break;
		case OTAccount::mint:
			strAcctType.Set("mint");
			break;
		case OTAccount::voucher:
			strAcctType.Set("voucher");
			break;
		case OTAccount::stash:
			strAcctType.Set("stash");
			break;
		default:
			strAcctType.Set("err_acct");
			break;
	}
}
开发者ID:BugFreeSoftware,项目名称:Open-Transactions,代码行数:30,代码来源:OTAccount.cpp

示例2: Listen

void OTSocket::Listen(const OTString &strBind)
{
	if (NULL != m_pSocket)
		delete m_pSocket;
//	m_pSocket = NULL;
	m_pSocket = new zmq::socket_t(*m_pContext, ZMQ_REP);  // RESPONSE socket (Request / Response.)
	OT_ASSERT_MSG(NULL != m_pSocket, "OTSocket::Listen: new zmq::socket(context, ZMQ_REP)");
	
	OTString strTemp(strBind); // In case m_strBindPath is what was passed in. (It happens.)
	m_strBindPath.Set(strTemp); // In case we have to close/reopen the socket to finish a send/receive.
	
	// ------------------------
	//  Configure socket to not wait at close time
    //
	const int linger = 0; // close immediately
	m_pSocket->setsockopt (ZMQ_LINGER, &linger, sizeof (linger));
    /*
     int zmq_setsockopt (void *socket, int option_name, const void *option_value, size_t option_len);
     
     Caution: All options, with the exception of ZMQ_SUBSCRIBE, ZMQ_UNSUBSCRIBE and ZMQ_LINGER, only take effect for subsequent socket bind/connects.     
     */
    
	// ------------------------
    
	m_pSocket->bind(strBind.Get());
}
开发者ID:seanmerriam,项目名称:Open-Transactions,代码行数:26,代码来源:xmlrpcxx_server.cpp

示例3: Win_GetInstallFolderFromRegistry

const bool OTPaths::Win_GetInstallFolderFromRegistry(OTString & out_InstallFolderPath)
{
	WindowsRegistryTools windowsRegistryTools;




	HKEY hKey=0;
	LONG lRes = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Open-Transactions", 0, KEY_READ, &hKey);
	bool bExistsAndSuccess (lRes == ERROR_SUCCESS);
	bool bDoesNotExistsSpecifically (lRes == ERROR_FILE_NOT_FOUND);

	std::wstring strValueOfBinDir;
	windowsRegistryTools.GetStringRegKey(hKey, L"Path", strValueOfBinDir, L"bad");

	if (bExistsAndSuccess)
	{
		std::string strInstallPath(OTString::ws2s(strValueOfBinDir));
		out_InstallFolderPath.Set(strInstallPath.c_str());

		return true;
	}

	
	return false;
}
开发者ID:Sollo,项目名称:Open-Transactions,代码行数:26,代码来源:OTPaths.cpp

示例4: TransformFilePath

// static
// Changes ~/blah to /Users/au/blah
//
void OTLog::TransformFilePath(const char * szInput, OTString & strOutput)
{
    if (NULL == szInput)
        return;
    
#ifndef _WIN32 // if UNIX (NOT windows)
	wordexp_t exp_result;
	wordexp(szInput, &exp_result, 0);
	
	strOutput.Set(exp_result.we_wordv[0]);
    
	wordfree(&exp_result); 
#else
	strOutput.Set(szInput);
#endif  
}
开发者ID:jarlfenrir,项目名称:Open-Transactions,代码行数:19,代码来源:OTLog.cpp

示例5: GetOTAppDataFolderLocation

// ***********************************************************************
//
// INI FILE
//
bool GetOTAppDataFolderLocation(OTString strIniFileDefault, OTString & strOTServerDataLocation)
{
    CSimpleIniA ini;
    SI_Error rc = ini.LoadFile(strIniFileDefault.Get());
    if (rc >=0)
    {
        {
            const char * pVal = ini.GetValue("paths", "server_path", SERVER_PATH_DEFAULT); // todo stop hardcoding.
            
            if (NULL != pVal)
            {
                strOTServerDataLocation.Set(pVal);
                OTLog::vOutput(0, "Reading ini file (%s). \n Found Server data_folder path: %s \n", 
                               strIniFileDefault.Get(), strOTServerDataLocation.Get());
                return true;
            }
            
            OTLog::vOutput(0, "Reading ini file (%s) \n", strIniFileDefault.Get());
            return false;
        }            
    }
    else 
    {
        OTLog::vOutput(0, "Unable to load ini file (%s) to find data_folder path \n", 
                       strIniFileDefault.Get());
        return false;
    }
}
开发者ID:seanmerriam,项目名称:Open-Transactions,代码行数:32,代码来源:main.cpp

示例6: FormatShortMailDescription

// ---------------------------------------
bool MTRecord::FormatShortMailDescription(std::string & str_output)
{
    OTString strDescription;

    if (IsMail())
    {
        if (!HasContents())
            strDescription.Set("(empty message)");
        else
        {
            std::string str_contents = GetContents();

            if (str_contents.compare(0,8,"Subject:") == 0)
            {
                // Make the replacement.
                str_contents.replace(0, 8, "");
            }
            // -----------------------------------
            bool bTruncated = false;

            if (str_contents.size() > 30)
            {
                str_contents.erase(30, std::string::npos);
                bTruncated = true;
            }
            // -----------------------------------
            strDescription.Format("\"%s%s\"", OTString::trim(str_contents).c_str(),
                                  bTruncated ? "..." : "");
        }
    }
    // -----------------------------
    str_output = strDescription.Get();
    // -----------------------------
    return (!str_output.empty());
}
开发者ID:kazcw,项目名称:Moneychanger,代码行数:36,代码来源:MTRecord.cpp

示例7: Truncate

void OTString::Truncate(uint32_t lAt)
{
    OTString strTruncated;

    strTruncated.Set(this->Get(), lAt);

    this->Set(strTruncated);
}
开发者ID:kazcw,项目名称:Open-Transactions,代码行数:8,代码来源:OTString.cpp

示例8: GetAndUnpackString

/// if we pack, compress, encode on the way in, that means, therefore, we
/// need to decode, uncompress, then unpack on our way out. Right?
///
/// This function will base64-DECODE the string contents, then uncompress them using
/// zlib, and then unpack the result using whatever is the default packer (MsgPack, Protobuf, etc).
/// 
/// I originally added compression because message sizes were too big. Now I'm adding packing, 
/// to solve any issues of binary compatibility across various platforms.
//
bool OTASCIIArmor::GetAndUnpackString(OTString & strData, bool bLineBreaks) const //bLineBreaks=true
{	
	size_t		outSize	= 0;
	uint8_t *	pData	= NULL;
	
	strData.Release();
	
	if (GetLength() < 1)
	{
		return true;
	}
	// --------------------------------------------------------------
	pData = OTCrypto::It()->Base64Decode(this->Get(), &outSize, bLineBreaks);
//	pData = OT_base64_decode(Get(), &outSize, (bLineBreaks ? 1 : 0));
	
	if (pData)
	{
        
        std::string str_decoded( pData, pData+outSize );
        
        delete [] pData; pData=NULL;

        std::string str_uncompressed = decompress_string( str_decoded );
		// ---------------------------------------
		// PUT THE PACKED BUFFER HERE, AND UNPACK INTO strData
		// --------------------------------------------------------
		OTDB::OTPacker * pPacker = OTASCIIArmor::GetPacker(); // No need to check for failure, since this already ASSERTS. No need to cleanup either.
		
		OTDB::PackedBuffer * pBuffer = pPacker->CreateBuffer(); // Need to clean this up.
		OT_ASSERT(NULL != pBuffer);
		OTCleanup<OTDB::PackedBuffer> theBufferAngel(*pBuffer); // This will make sure buffer is deleted later.
		      
        pBuffer->SetData(reinterpret_cast<const uint8_t *>(str_uncompressed.data()), str_uncompressed.size());
		// -----------------------------
		OTDB::OTDBString * pOTDBString = dynamic_cast<OTDB::OTDBString *>(OTDB::CreateObject(OTDB::STORED_OBJ_STRING));
		OT_ASSERT(NULL != pOTDBString);
		OTCleanup<OTDB::OTDBString> theStringAngel(*pOTDBString); // clean up this string.
		
		bool bUnpacked = pPacker->Unpack(*pBuffer, *pOTDBString);
		// ----------------------
		if (false == bUnpacked)
		{
			OTLog::Error("Failed unpacking string in OTASCIIArmor::GetAndUnpackString.\n");
			
			return false;
		}
		// --------------------------------------------------------
		// This enforces the null termination. (using the 2nd parameter as nEnforcedMaxLength)
		strData.Set(pOTDBString->m_string.c_str(), static_cast<uint32_t> (pOTDBString->m_string.length()));
		
		return true;
	}
	else 
	{
		OTLog::Error("OTASCIIArmor::GetAndUnpackString: NULL pData while base64-decoding pData.\n");
		return false;
	}
}
开发者ID:BwRy,项目名称:Open-Transactions,代码行数:67,代码来源:OTASCIIArmor.cpp

示例9: GetExecutable

const bool GetExecutable(OTString & strExecutablePath)
{
#ifdef TARGET_OS_MAC
	char bufPath[PATH_MAX + 1]="";
	uint32_t size = sizeof(bufPath);
	int  bufsize = sizeof(bufPath);
	if (_NSGetExecutablePath(bufPath, &size) == 0)
		strExecutablePath.Set(bufPath);
	else return false;
#elif defined __linux__

	char buff[4096]="";
	ssize_t len = ::readlink("/proc/self/exe", buff, sizeof(buff)-1);
	if (len != -1) {  // good
		buff[len] = '\0';
		strExecutablePath.Set(buff);
	}
	else {  // bad
		strExecutablePath.Set("");
		return false;
	}

#elif defined _WIN32

#ifdef _UNICODE
	TCHAR bufPath[ _MAX_PATH+1 ] = L"";
#else
	TCHAR bufPath[ _MAX_PATH+1 ] = "";
#endif

	GetModuleFileName( NULL , bufPath , sizeof(bufPath)/sizeof(TCHAR) ) ;

#ifdef UNICODE
	strExecutablePath.Set(utf8util::UTF8FromUTF16(bufPath));
#else
	strExecutablePath.Set(bufPath);
#endif
#else
	return false;
#endif
	return true;
}
开发者ID:Sollo,项目名称:Open-Transactions,代码行数:42,代码来源:OTPaths.cpp

示例10: FixPath

const bool OTPaths::FixPath(const OTString & strPath, OTString & out_strFixedPath, const bool & bIsFolder)
{
	if (!strPath.Exists())			{ OTLog::sError("%s: Null: %s passed in!\n", __FUNCTION__, "strPath"	); OT_ASSERT(false); }



	std::string l_strPath(strPath.Get());
	// first change all back-slashes to forward slashes:
	std::string l_strPath_noBackslash(OTString::replace_chars(l_strPath,"\\",'/'));


	// now we make sure we have the correct trailing "/".

	if ('/' == *l_strPath_noBackslash.rbegin())
	{
		if (bIsFolder)
		{
			out_strFixedPath.Set(l_strPath_noBackslash.c_str());
			return true;
		}
		else
		{
			out_strFixedPath.Set(l_strPath_noBackslash.substr(0, l_strPath_noBackslash.size()-1).c_str());
			return true;
		}
	}
	else
	{
		if (bIsFolder)
		{
			l_strPath_noBackslash += "/";
			out_strFixedPath.Set(l_strPath_noBackslash.c_str());
			return true;
		}
		else
		{
			out_strFixedPath.Set(l_strPath_noBackslash.c_str());
			return true;
		}
	}
}
开发者ID:Sollo,项目名称:Open-Transactions,代码行数:41,代码来源:OTPaths.cpp

示例11: LoadFrom_ifstream

// This code reads up the file, discards the bookends, and saves only the gibberish itself.
bool OTASCIIArmor::LoadFrom_ifstream(std::ifstream & fin)
{
	std::stringstream buffer;
	buffer << fin.rdbuf();
	
	std::string contents(buffer.str());
	
	OTString theString;
	theString.Set(contents.c_str());
	
	return LoadFromString(theString);
}
开发者ID:9cat,项目名称:Open-Transactions,代码行数:13,代码来源:OTASCIIArmor.cpp

示例12: TransformFilePath

// static
// Changes ~/blah to /Users/au/blah
//
void OTLog::TransformFilePath(const char * szInput, OTString & strOutput)
{
    OT_ASSERT(NULL != szInput);
     	
#ifndef _WIN32 // if UNIX (NOT windows)
	wordexp_t exp_result;
	
	if (wordexp(szInput, &exp_result, 0))
	{
		OTLog::Error("OTLog::TransformFilePath: Error calling wordexp() to expand path.\n");
		wordfree(&exp_result); 
		strOutput.Set(szInput);
		return;
	}
	// ----------------------------
	
	std::string str_Output("");
	
	// wordexp tokenizes by space (as well as expands, which is why I'm using it.)
	// Therefore we need to iterate through the tokens, and create a single string
	// with spaces between the tokens.
	//
	for (int i = 0; exp_result.we_wordv[i] != NULL; i++)
	{
		str_Output += exp_result.we_wordv[i];
		
		if (exp_result.we_wordv[i+1] != NULL)
			str_Output += " ";
	}
	
	wordfree(&exp_result); 

    if (str_Output.size() > 0)
        strOutput.Set(str_Output.c_str());
    else
        strOutput.Set(szInput);
#else
	strOutput.Set(szInput);
#endif  
}
开发者ID:DocMerlin,项目名称:Open-Transactions,代码行数:43,代码来源:OTLog.cpp

示例13: GetOTAppDataFolderLocation

// ***********************************************************************
//
// INI FILE
//
bool GetOTAppDataFolderLocation(const OTString & strIniFileDefault, OTString & strOTServerDataLocation)
{
    CSimpleIniA ini;
    SI_Error rc = ini.LoadFile(strIniFileDefault.Get());
    if (rc >=0)
    {
        {
            const char * pVal = ini.GetValue("paths", "prefix_path", OT_PREFIX_DEFAULT); // todo stop hardcoding.
            
            if (NULL != pVal)
            {
                OTLog::SetPrefixPath(pVal);
                OTLog::vOutput(0, "server main: Reading ini file (%s). \n Found prefix_path: %s \n", 
                               strIniFileDefault.Get(), OTLog::PrefixPath());
            }
            else
                OTLog::vOutput(0, "server main:Ini file: %s: Failed to find prefix_path. \n", strIniFileDefault.Get());
        }            
        {
            const char * pVal = ini.GetValue("paths", "init_path", OT_FOLDER_DEFAULT); // todo stop hardcoding.
            
            if (NULL != pVal)
            {
                OTLog::SetConfigPath(pVal);
                OTLog::vOutput(0, "server main: Reading ini file (%s). \n Found Server init_path: %s \n", 
                               strIniFileDefault.Get(), OTLog::ConfigPath());
            }
            else
                OTLog::vOutput(0, "server main:Ini file: %s: Failed to find init_path. \n", strIniFileDefault.Get());
        }            
        {
            const char * pVal = ini.GetValue("paths", "server_path", SERVER_PATH_DEFAULT); // todo stop hardcoding.
            
            if (NULL != pVal)
            {
                strOTServerDataLocation.Set(pVal);
                OTLog::vOutput(0, "server main: Reading ini file (%s). \n Found Server data_folder path: %s \n", 
                               strIniFileDefault.Get(), strOTServerDataLocation.Get());
                return true;
            }
            
            OTLog::vOutput(0, "server main: Reading ini file (%s) \n", strIniFileDefault.Get());
            return false;
        }            
    }
    else 
    {
        OTLog::vOutput(0, "server main: Unable to load ini file (%s) to find data_folder path \n", 
                       strIniFileDefault.Get());
        return false;
    }
}
开发者ID:seanmerriam,项目名称:Open-Transactions,代码行数:56,代码来源:xmlrpcxx_server.cpp

示例14: GetHomeFromSystem

const bool OTPaths::GetHomeFromSystem(OTString & out_strHomeFolder)
{
#ifdef _WIN32
#ifdef _UNICODE
	TCHAR szPath[MAX_PATH]=L"";
#else
	TCHAR szPath[MAX_PATH]="";
#endif

	if(SUCCEEDED(SHGetFolderPath(NULL, CSIDL_APPDATA|CSIDL_FLAG_CREATE, NULL, 0, szPath))) {
#ifdef UNICODE
		out_strHomeFolder.Set(utf8util::UTF8FromUTF16(szPath));
#else
		out_strHomeFolder.Set(szPath);
#endif
	}
	else { out_strHomeFolder.Set(""); return false; }
#else
	out_strHomeFolder.Set(getenv("HOME"));
#endif
	return true;
}
开发者ID:Sollo,项目名称:Open-Transactions,代码行数:22,代码来源:OTPaths.cpp

示例15: GetCurrentWorking

const bool GetCurrentWorking(OTString & strCurrentWorkingPath)
{

#ifdef _WIN32
	// Windows Common
	TCHAR * szPath = NULL;
#ifdef _UNICODE
	// Windows Unicode
#define GetCurrentDir _wgetcwd
#else
	// Windows No-Unicode
#define GetCurrentDir _getcwd
#endif
#else
	// Unix
#define GetCurrentDir getcwd
	char * szPath = NULL;
#endif

	// All
	bool r = ((szPath = GetCurrentDir(NULL,0)) == 0);
	OT_ASSERT(0 != r);

	OTString result;

#ifdef _WIN32
#ifdef _UNICODE
	// Windows Unicode
	strCurrentWorkingPath.Set(utf8util::UTF8FromUTF16(szPath));
#endif
#else
	// Unix
	strCurrentWorkingPath.Set(szPath);
#endif
	// All
	return true;
}
开发者ID:Sollo,项目名称:Open-Transactions,代码行数:37,代码来源:OTPaths.cpp


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