本文整理汇总了C++中Tstring类的典型用法代码示例。如果您正苦于以下问题:C++ Tstring类的具体用法?C++ Tstring怎么用?C++ Tstring使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Tstring类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetDlgItem
void CColourBox::PopulateList() {
HWND ListBox = GetDlgItem(m_hwnd, IDC_COLOURS);
SendMessage(ListBox, LB_RESETCONTENT, 0, 0);
m_pDasherInterface->GetPermittedValues(SP_COLOUR_ID, ColourList);
// Add each string to list box and index each one
bool SelectionSet = false;
for(unsigned int i = 0; i < ColourList.size(); i++) {
Tstring Item;
WinUTF8::UTF8string_to_wstring(ColourList[i], Item);
LRESULT Index = SendMessage(ListBox, LB_ADDSTRING, 0, (LPARAM) Item.c_str());
SendMessage(ListBox, LB_SETITEMDATA, Index, (LPARAM) i);
if(ColourList[i] == m_CurrentColours) {
SendMessage(ListBox, LB_SETCURSEL, Index, 0);
SelectionSet = true;
}
}
if(SelectionSet == false) {
SendMessage(ListBox, LB_SETCURSEL, 0, 0);
LRESULT CurrentIndex = SendMessage(ListBox, LB_GETITEMDATA, 0, 0);
m_CurrentColours = ColourList[CurrentIndex];
}
// Tell list box that we have set an item for it (so that delete and edit can be grayed if required)
SendMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_COLOURS, LBN_SELCHANGE), 0);
}
示例2: SETVALUE
void TestAbortQuery::createPINs(int pNumPINs)
{
mLogger.out() << " Creating " << pNumPINs << " PINs ...";
int i = 0;
for(i = 0; i < pNumPINs; i++)
{
if(i % 100 == 0) mLogger.out() << ".";
PID lPID;
Value lV[20];
SETVALUE(lV[0], mPropIDs[0], i, OP_SET);
Tstring lStr; MVTRand::getString(lStr, 100, 100, true, false);
SETVALUE(lV[1], mPropIDs[1], lStr.c_str(), OP_SET);
SETVALUE(lV[2], mPropIDs[2], lStr.c_str(), OP_SET);
Tstring lWStr; MVTRand::getString(lWStr, 100, 100, true, false);
SETVALUE(lV[3], mPropIDs[3], lWStr.c_str(), OP_SET);
double lDouble = (double)MVTRand::getRange(10, 1000);
SETVALUE(lV[4], mPropIDs[4], lDouble, OP_SET);
SETVALUE(lV[5], mPropIDs[5], MVTRand::getBool(), OP_SET);
lV[6].setNow(); SETVATTR(lV[6], mPropIDs[6], OP_SET);
lV[7].setNow(); SETVATTR(lV[7], mPropIDs[7], OP_SET);
IStream *lStream = new TestStringStream(MVTRand::getRange(10, 30) * 1024);
SETVALUE(lV[8], mPropIDs[8], MVTApp::wrapClientStream(mSession, lStream), OP_SET);
IStream *lStream1 = new TestStringStream(MVTRand::getRange(10, 30) * 1024);
SETVALUE(lV[9], mPropIDs[9], MVTApp::wrapClientStream(mSession, lStream1), OP_SET);
SETVALUE(lV[10], PROP_SPEC_CREATED, 1, OP_SET);
SETVALUE(lV[11], PROP_SPEC_UPDATED, i, OP_SET);
CREATEPIN(mSession, &lPID, lV, 12);
}
mLogger.out() << " DONE " << std::endl;
}
示例3: LoadAccelerators
HWND CDasherWindow::Create() {
hAccelTable = LoadAccelerators(WinHelper::hInstApp, (LPCTSTR)IDC_DASHER);
// Get window title from resource script
Tstring WindowTitle;
WinLocalisation::GetResourceString(IDS_APP_TITLE, &WindowTitle);
string configFileName = "settings.xml";
if (!m_configName.empty())
configFileName = "settings." + WinUTF8::wstring_to_UTF8string(m_configName.c_str()) + ".xml";
static XmlErrorDisplay display;
static CWinFileUtils fileUtils;
auto settings = new Dasher::XmlSettingsStore(configFileName, &fileUtils, &display);
settings->Load();
// Save the defaults if needed.
settings->Save();
m_pAppSettings = new CAppSettings(0, 0, settings); // Takes ownership of the settings store.
int iStyle(m_pAppSettings->GetLongParameter(APP_LP_STYLE));
HWND hWnd;
if (iStyle == APP_STYLE_DIRECT) {
hWnd = CWindowImpl<CDasherWindow >::Create(NULL, NULL, WindowTitle.c_str(), WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, WS_EX_NOACTIVATE | WS_EX_APPWINDOW | WS_EX_TOPMOST);
::SetMenu(hWnd, NULL);
}
else {
hWnd = CWindowImpl<CDasherWindow >::Create(NULL, NULL, WindowTitle.c_str(), WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN);
::SetMenu(hWnd, m_hMenu);
}
// Create Widgets
m_pEdit = new CEdit(m_pAppSettings);
m_pEdit->Create(hWnd, m_pAppSettings->GetBoolParameter(APP_BP_TIME_STAMP));
m_pEdit->SetFont(m_pAppSettings->GetStringParameter(APP_SP_EDIT_FONT), m_pAppSettings->GetLongParameter(APP_LP_EDIT_FONT_SIZE));
m_pDasher = new CDasher(hWnd, this, m_pEdit, settings, &fileUtils);
// Create a CAppSettings
m_pAppSettings->SetHwnd(hWnd);
m_pAppSettings->SetDasher(m_pDasher);
m_pToolbar = new CToolbar(hWnd, m_pAppSettings->GetBoolParameter(APP_BP_SHOW_TOOLBAR));
// FIXME - the edit box really shouldn't need access to the interface,
// but at the moment it does, for training, blanking the display etc
m_pEdit->SetInterface(m_pDasher);
m_pSpeedAlphabetBar = new CStatusControl(m_pDasher->GetSettingsUser(), m_pAppSettings);
m_pSpeedAlphabetBar->Create(hWnd);
m_pSplitter = new CSplitter(this, 100);
m_pSplitter->Create(hWnd);
m_bFullyCreated = true;
return hWnd;
}
示例4: if
Tstring & TestMeanSql::gen_value(GenCtx & pCtx, Tstring & pResult)
{
size_t i;
Tstring lV;
std::ostringstream lOs;
// Either generate a good value...
if (pCtx.doGood())
{
int const lType = MVTRand::getRange(0, 15);
switch (lType)
{
// Note: We don't generate collections here, because it's not (yet) a recursive structure, and here we're supposed to be 'good'.
case 0: default: MVTRand::getString(lV, 5, 15, true, true); lOs << "'" << lV << "'"; break;
case 1: lOs << MVTRand::getRange(0, std::numeric_limits<int>::max()); if (MVTRand::getBool()) lOs << "U"; break;
case 2: lOs << MVTRand::getFloatRange(0.0, std::numeric_limits<float>::max()) << "f"; break;
case 3: lOs << MVTRand::getDoubleRange(0.0, std::numeric_limits<double>::max()); break;
case 4: lOs << (MVTRand::getBool() ? "TRUE" : "FALSE"); break;
case 5: MVTRand::getString(lV, 5, 15, true, true); lOs << "U'http://" << lV << "'"; break;
case 6: MVTRand::getString(lV, 5, 15, true, true); lOs << "X'"; for (i = 0; i < lV.length(); i++) { lOs << std::hex << std::setw(2) << std::setfill('0') << (int)lV.at(i); } lOs << std::dec << "'"; break;
case 7: lOs << "INTERVAL'" << MVTRand::getRange(0, std::numeric_limits<int>::max()) << ":" << std::setw(2) << std::setfill('0') << MVTRand::getRange(0, 59) << ":" << MVTRand::getRange(0, 59) << ".12345'"; break;
case 8: lOs << "TIMESTAMP'" << std::setw(4) << std::setfill('0') << MVTRand::getRange(0, 2200) << "-" << std::setw(2) << MVTRand::getRange(1, 12) << "-" << MVTRand::getRange(1, 31) << " " << MVTRand::getRange(0, 23) << ":" << MVTRand::getRange(0, 59) << ":" << MVTRand::getRange(0, 59); break;
case 9: lOs << "@" << std::hex << MVTRand::getRange(0x50001, 0x500001) << std::dec; break;
case 10: lOs << "@" << std::hex << MVTRand::getRange(0x50001, 0x500001) << "." << randomProperty() << std::dec; break;
case 11: lOs << "@" << std::hex << MVTRand::getRange(0x50001, 0x500001) << "." << randomProperty() << std::dec << "["; if (MVTRand::getBool()) lOs << ":FIRST"; else lOs << MVTRand::getRange(0, 100); lOs << "]"; break;
case 12: lOs << gen_SELECT(pCtx, lV); break; // Not necessarily 'good' currently, but who cares...
case 13: lOs << "${" << gen_SELECT(pCtx, lV) << "}"; break;
}
}
// Or generate a bad value...
else
{
int const lType = MVTRand::getRange(0, 18);
switch (lType)
{
// Note: We do generate collections here, because here all is permitted :).
case 0: default:
#if TEST_ISSUE_DOUBLE_QUOTED_VAL
MVTRand::getString(lV, 5, 15, true, true); lOs << "\"" << lV << "\""; break;
#endif
case 1: lOs << MVTRand::getRange(0, std::numeric_limits<int>::max()) << "bla"; break;
case 2: lOs << MVTRand::getRange(0, std::numeric_limits<int>::max()) << MVTRand::getRange(0, std::numeric_limits<int>::max()) << MVTRand::getRange(0, std::numeric_limits<int>::max()); break;
case 3: lOs << MVTRand::getFloatRange(0.0, std::numeric_limits<float>::max()) << "fbla"; break;
case 4: lOs << MVTRand::getDoubleRange(0.0, std::numeric_limits<double>::max()) << "bla"; break;
case 5: lOs << MVTRand::getDoubleRange(0.0, std::numeric_limits<double>::max()) << MVTRand::getDoubleRange(0.0, std::numeric_limits<double>::max()); break;
case 6: lOs << randomKeyword(); break;
case 7: lOs << gen_collection(pCtx, lV); break;
case 8: lOs << "MAYBE"; break;
case 9: MVTRand::getString(lV, 5, 15, true, true); lOs << "U'http://" << lV << (pCtx.doGood() ? "'" : ""); break;
case 10: MVTRand::getString(lV, 5, 15, true, true); lOs << "X'"; for (i = 0; i < lV.length(); i++) { lOs << std::hex << (int)lV.at(i); } lOs << std::dec << (pCtx.doGood() ? "'" : ""); break;
case 11: lOs << "INTERVAL'"; if (pCtx.doGood()) lOs << MVTRand::getRange(0, std::numeric_limits<int>::max()); else lOs << MVTRand::getString(lV, 5, 15, false, true); lOs << ":" << MVTRand::getRange(0, pCtx.doGood() ? 59 : 1000) << (pCtx.doGood() ? ":" : ";") << MVTRand::getRange(0, pCtx.doGood() ? 59 : 1000) << ".12345'"; break;
case 12: lOs << "TIMESTAMP'" << MVTRand::getRange(0, 10000) << "-" << MVTRand::getRange(1, pCtx.doGood() ? 12 : 1000) << "-" << MVTRand::getRange(1, pCtx.doGood() ? 31 : 1000) << " " << MVTRand::getRange(0, pCtx.doGood() ? 23 : 1000) << ":" << MVTRand::getRange(0, 59) << ":" << MVTRand::getRange(0, 59); break;
case 13: lOs << "@"; if (pCtx.doGood()) lOs << std::hex << MVTRand::getRange(0x50001, 0x500001) << std::dec; else lOs << MVTRand::getString(lV, 5, 15, false, true); break;
case 14: lOs << "@" << std::hex << MVTRand::getRange(0x50001, 0x500001) << "." << (pCtx.doGood() ? randomProperty() : randomWord()) << std::dec; break;
case 15: lOs << "@" << std::hex << MVTRand::getRange(0x50001, 0x500001) << "." << randomProperty() << std::dec << "["; if (pCtx.doGood()) lOs << MVTRand::getRange(0, 100); else lOs << randomWord(); lOs << "]"; break;
case 16: lOs << "${" << gen_whatever(pCtx, lV) << "}"; break;
}
}
return pResult = lOs.str();
}
示例5: Create
HWND CEdit::Create(HWND hParent, bool bNewWithDate) {
m_hWnd = CWindowImpl<CEdit>::Create(hParent, NULL, NULL, ES_NOHIDESEL | WS_CHILD | ES_MULTILINE | WS_VSCROLL | WS_VISIBLE, WS_EX_CLIENTEDGE);
Tstring WindowTitle;
WinLocalisation::GetResourceString(IDS_APP_TITLE, &WindowTitle);
m_FilenameGUI = new CFilenameGUI(hParent, WindowTitle.c_str(), bNewWithDate);
return m_hWnd;
}
示例6: _type
freettcn::CType::CValue::CValue(const std::shared_ptr<const TciType> &type,
const Tstring &encoding,
const Tstring &encodingVariant):
_type(type)
{
if(encoding.empty() || encoding == type->getTypeEncoding())
_encoding.reset(new Tstring(encoding));
if(encodingVariant.empty() || encodingVariant == type->getTypeEncodingVariant())
_encoding.reset(new Tstring(encodingVariant));
}
示例7: switch
LRESULT CViewPage::WndProc(HWND Window, UINT message, WPARAM wParam, LPARAM lParam) {
// most things we pass on to CPrefsPageBase, but we need to handle slider motion
switch (message) {
case WM_COMMAND:
if(HIWORD(wParam)==BN_CLICKED || HIWORD(wParam)==LBN_SELCHANGE) {
if(LOWORD(wParam) != 0 && m_hPropertySheet != 0 && m_hwnd != 0) {
PropSheet_Changed(m_hPropertySheet, m_hwnd); // enables the 'Apply' button
// Behaviour isn't *perfect* since it activates the Apply button even if you, say,
// click 'new' alphabet then click Cancel when asked for a name.
}
}
switch (LOWORD(wParam)) {
case (IDC_COLOURS):
if(HIWORD(wParam) == LBN_SELCHANGE) {
HWND ListBox = GetDlgItem(m_hwnd, IDC_COLOURS);
LRESULT CurrentItem = SendMessage(ListBox, LB_GETCURSEL, 0, 0);
LRESULT CurrentIndex = SendMessage(ListBox, LB_GETITEMDATA, CurrentItem, 0);
m_CurrentColours = ColourList[CurrentIndex];
}
return TRUE;
break;
case IDC_DFONT_BUTTON:
// TODO: Put this in a function
{
CHOOSEFONT Data;
LOGFONT lf;
HFONT Font = (HFONT) GetStockObject(DEFAULT_GUI_FONT);
GetObject(Font, sizeof(LOGFONT), &lf);
Tstring tstrFaceName;
WinUTF8::UTF8string_to_wstring(m_pAppSettings->GetStringParameter(SP_DASHER_FONT), tstrFaceName);
_tcscpy(lf.lfFaceName, tstrFaceName.c_str());
Data.Flags = CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS;
Data.lStructSize = sizeof(CHOOSEFONT);
// TODO: Give this an owner
Data.hwndOwner = NULL;
Data.lpLogFont = &lf;
if(ChooseFont(&Data)) {
string FontName;
WinUTF8::wstring_to_UTF8string(lf.lfFaceName, FontName);
m_pAppSettings->SetStringParameter(SP_DASHER_FONT, FontName);
}
}
break;
case IDC_COLOURSCHEME:
EnableWindow(GetDlgItem(m_hwnd, IDC_COLOURS), SendMessage(GetDlgItem(m_hwnd, IDC_COLOURSCHEME), BM_GETCHECK, 0, 0) == BST_CHECKED);
break;
}
}
CPrefsPageBase::WndProc(Window, message, wParam, lParam);
}
示例8: SaveSetting
void CAppSettings::SaveSetting(const std::string &Key, long Value) {
Tstring TKey;
UTF8string_to_wstring(Key, TKey);
// Evil casting. Registry stores DWORD's (unsigned longs)
// I'm forcing in signed longs and if I force them out again in the same
// way I should get a sensible result.
DWORD *RegValue = (DWORD *) & Value;
DWORD MemAllow = sizeof(DWORD);
LONG ErrVal = RegSetValueEx(ProductKey, TKey.c_str(), 0,
REG_DWORD, (const unsigned char *)RegValue, MemAllow);
}
示例9: testRandomStatement
// Simplest sub-test (meaningless random arrangements of keywords and keynames).
void TestMeanSql::testRandomStatement(ISession & pSession, size_t pMinWords, size_t pMaxWords)
{
size_t i;
size_t const lNumWords = MVTRand::getRange(pMinWords, pMaxWords);
Tstring lStmt;
for (i = 0; i < lNumWords; i++)
{
lStmt += MVTRand::getRange(0, 100) > 95 ? "@50001" : randomWord();
lStmt += " ";
}
testStmt(&pSession, lStmt.c_str());
}
示例10: QuerySaveFirst
int CFilenameGUI::QuerySaveFirst() {
if(Dirty) {
Tstring ResourceString;
Tstring Title;
WinLocalisation::GetResourceString(IDS_QUERY_SAVE_CHANGES, &ResourceString);
WinLocalisation::GetResourceString(IDS_UNSAVED_CHANGES, &Title);
return MessageBox(WindowWithTitlebar, ResourceString.c_str(), Title.c_str(), MB_YESNOCANCEL | MB_ICONWARNING | MB_DEFBUTTON1 | MB_APPLMODAL);
}
return IDNO;
}
示例11: TVERIFYRC
int TestPageInsertOverflow::execute()
{
bool lSuccess = true;
if (MVTApp::startStore())
{
ISession * session = MVTApp::startSession();
Value val[sNumProps];PID pid1;IPIN *pin1;
MVTApp::mapURIs(session, "TestPageInsertOverflow.prop.", sNumProps, lPropIDs);
TVERIFYRC(session->createPIN(NULL,0,&pin1,MODE_PERSISTENT));
pid1 = pin1->getPID();
if(pin1!=NULL) pin1->destroy();
for (int i=0; i < 10; i++)
{
IPIN *pin;Tstring str;int k=0;int x=0;
for (k=0; k < 10; k++)
{
MVTApp::randomString(str,1,30);
val[k].set(str.c_str());val[k].setPropID(lPropIDs[k]);
}
TVERIFYRC(session->createPIN(val,k-1,&pin,MODE_PERSISTENT|MODE_COPY_VALUES));
for (x =0; x < 10;x++,k++)
{
val[x].set(pid1);val[x].setPropID(lPropIDs[k]);
val[x].op = OP_ADD;val[x].eid = STORE_FIRST_ELEMENT;
}
TVERIFYRC(pin->modify(val,x));
for (x =0; x < 40;x++,k++)
{
val[x].set("a");val[x].setPropID(lPropIDs[k]);
}
TVERIFYRC(pin->modify(val,x));
for (x =0; x < 10;x++,k++)
{
val[x].set(pid1);val[x].setPropID(lPropIDs[k]);
val[x].op = OP_ADD;val[x].eid = STORE_FIRST_ELEMENT;
}
TVERIFYRC(pin->modify(val,x));
for (x =0; x < 10;x++,k++)
{
val[x].set(pid1);val[x].setPropID(lPropIDs[k]);
}
session->startTransaction();
TVERIFYRC(pin->modify(val,x));
if(pin!=NULL) pin->destroy();
session->rollback();
}
session->terminate();
MVTApp::stopStore();
}
else { TVERIFY(!"could not open store") ; }
return lSuccess ? 0 : 1;
}
示例12: testStmt
void testStmt(ISession * pSession, Tstring const & pStmt)
{
if (isKnownFailure(pStmt))
return;
mLogger.out() << "tried: " << pStmt.c_str() << std::endl;
CompilationError lCE;
CmvautoPtr<IStmt> lStmt(pSession->createStmt(pStmt.c_str(), NULL, 0, &lCE));
mLogger.out() << "obtained: " << lCE.rc << " " << (lCE.msg ? lCE.msg : "") << std::endl << std::endl;
#if TEST_EXECUTE_GOOD_STMT
if (RC_OK == lCE.rc && lStmt.IsValid())
lStmt->execute();
#endif
}
示例13: search
unsigned long search(TSearchInfo pSearchInfo, unsigned long pExpResults, unsigned int *pFlags = NULL)
{
unsigned int lFlags = 0;
TV_R(!pSearchInfo.empty(), mTest);
uint64_t cntResults = 0 ;
CmvautoPtr<IStmt> ftQ(mSession->createStmt()) ;
unsigned char lVar = ftQ->addVariable() ;
TSearchInfo::const_iterator lIter = pSearchInfo.begin();
int i = 0;
for(; lIter != pSearchInfo.end(); lIter++, i++)
{
//string strFlags;
//if ( pFlags[i] & QFT_FILTER_SW ) strFlags.append( "QFT_FILTER_SW ");
//if ( pFlags[i] & MODE_ALL_WORDS ) strFlags.append( "MODE_ALL_WORDS ");
PropertyID lPropID = lIter->first;
Tstring lSearchKey = lIter->second;
unsigned int flagsToAddConditionFT = 0;
if (pFlags && pFlags[i])
{
lFlags |= pFlags[i];
if (pFlags[i] & QFT_FILTER_SW)
{
flagsToAddConditionFT |= QFT_FILTER_SW;
lFlags &= ~QFT_FILTER_SW ;
}
}
TVRC_R( ftQ->addConditionFT( lVar, lSearchKey.c_str(), flagsToAddConditionFT, &lPropID, 1), mTest);
}
TVRC_R( ftQ->count( cntResults, NULL, 0, ~0, lFlags ), mTest );
ICursor* lC = NULL;
ftQ->execute(&lC, NULL, 0, ~0, 0, lFlags);
CmvautoPtr<ICursor> res(lC);
PID lPID ;
unsigned long cntCheck = 0 ;
while( RC_OK == res->next(lPID) )
{
if (mTest->isVerbose())
MVTApp::output(lPID, std::cout, mSession);
cntCheck++ ;
}
TV_R(cntCheck == pExpResults, mTest) ;
TV_R(cntCheck == cntResults, mTest) ;
return (unsigned long)cntResults ;
}
示例14: SaveSettingT
void CAppSettings::SaveSettingT(const std::string &Key, const Tstring &TValue) {
Tstring TKey;
UTF8string_to_wstring(Key, TKey);
DWORD MemAllow = (TValue.size() + 1) * sizeof(TCHAR);
//const unsigned char* StrInput = (const unsigned char*) Value.c_str();
//LONG ErrVal = RegSetValueEx(ProductKey, TKey.c_str(), 0,
// REG_SZ, StrInput, MemAllow);
LONG ErrVal = RegSetValueEx(ProductKey, TKey.c_str(), 0,
REG_SZ, (CONST BYTE *) TValue.c_str(), MemAllow);
}
示例15: SetWindowTitle
void CFilenameGUI::SetWindowTitle() {
Tstring TitleText;
TCHAR PrettyName[_MAX_FNAME];
if(GetFileTitle(FileAndPath.c_str(), PrettyName, _MAX_FNAME) == 0)
TitleText = PrettyName;
else
WinLocalisation::GetResourceString(IDS_UNTITLED_FILE, &TitleText);
if(Dirty)
TitleText += TEXT("*");
TitleText += TEXT(" - ");
TitleText += AppName;
SendMessage(WindowWithTitlebar, WM_SETTEXT, 0, (LPARAM) TitleText.c_str());
}