本文整理汇总了C++中Ztring::To_Local方法的典型用法代码示例。如果您正苦于以下问题:C++ Ztring::To_Local方法的具体用法?C++ Ztring::To_Local怎么用?C++ Ztring::To_Local使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ztring
的用法示例。
在下文中一共展示了Ztring::To_Local方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Delete
//---------------------------------------------------------------------------
bool File::Delete(const Ztring &File_Name)
{
#ifdef ZENLIB_USEWX
return wxRemoveFile(File_Name.c_str());
#else //ZENLIB_USEWX
#ifdef ZENLIB_STANDARD
#ifdef UNICODE
return unlink(File_Name.To_Local().c_str())==0;
#else
return unlink(File_Name.c_str())==0;
#endif //UNICODE
#elif defined WINDOWS
#ifdef UNICODE
#ifndef ZENLIB_NO_WIN9X_SUPPORT
if (IsWin9X_Fast())
return DeleteFileA(File_Name.To_Local().c_str())!=0;
else
#endif //ZENLIB_NO_WIN9X_SUPPORT
return DeleteFileW(File_Name.c_str())!=0;
#else
return DeleteFile(File_Name.c_str())!=0;
#endif //UNICODE
#endif
#endif //ZENLIB_USEWX
}
示例2: Exists
//---------------------------------------------------------------------------
bool File::Exists(const Ztring &File_Name)
{
#ifdef ZENLIB_USEWX
wxFileName FN(File_Name.c_str());
return FN.FileExists();
#else //ZENLIB_USEWX
#ifdef ZENLIB_STANDARD
struct stat buffer;
int status;
#ifdef UNICODE
status=stat(File_Name.To_Local().c_str(), &buffer);
#else
status=stat(File_Name.c_str(), &buffer);
#endif //UNICODE
return status==0 && S_ISREG(buffer.st_mode);
#elif defined WINDOWS
#ifdef UNICODE
DWORD FileAttributes;
if (IsWin9X())
FileAttributes=GetFileAttributesA(File_Name.To_Local().c_str());
else
FileAttributes=GetFileAttributesW(File_Name.c_str());
#else
DWORD FileAttributes=GetFileAttributes(File_Name.c_str());
#endif //UNICODE
return ((FileAttributes!=INVALID_FILE_ATTRIBUTES) && !(FileAttributes&FILE_ATTRIBUTE_DIRECTORY));
#endif
#endif //ZENLIB_USEWX
}
示例3: Exists
//---------------------------------------------------------------------------
bool Dir::Exists(const Ztring &File_Name)
{
#ifdef ZENLIB_USEWX
wxFileName FN(File_Name.c_str());
return FN.DirExists();
#else //ZENLIB_USEWX
#ifdef WINDOWS
#ifdef UNICODE
DWORD FileAttributes;
#ifndef ZENLIB_NO_WIN9X_SUPPORT
if (IsWin9X_Fast())
FileAttributes=GetFileAttributesA(File_Name.To_Local().c_str());
else
#endif //ZENLIB_NO_WIN9X_SUPPORT
FileAttributes=GetFileAttributesW(File_Name.c_str());
#else
DWORD FileAttributes=GetFileAttributes(File_Name.c_str());
#endif //UNICODE
return ((FileAttributes!=INVALID_FILE_ATTRIBUTES) && (FileAttributes&FILE_ATTRIBUTE_DIRECTORY));
#else //WINDOWS
struct stat buffer;
int status;
#ifdef UNICODE
status=stat(File_Name.To_Local().c_str(), &buffer);
#else
status=stat(File_Name.c_str(), &buffer);
#endif //UNICODE
return status==0 && S_ISDIR(buffer.st_mode);
#endif
#endif //ZENLIB_USEWX
}
示例4: Exists
//---------------------------------------------------------------------------
bool File::Exists(const Ztring &File_Name)
{
#ifdef ZENLIB_USEWX
wxFileName FN(File_Name.c_str());
return FN.FileExists();
#else //ZENLIB_USEWX
#ifdef ZENLIB_STANDARD
if (File_Name.find(__T('*'))!=std::string::npos || File_Name.find(__T('?'))!=std::string::npos)
return false;
struct stat buffer;
int status;
#ifdef UNICODE
status=stat(File_Name.To_Local().c_str(), &buffer);
#else
status=stat(File_Name.c_str(), &buffer);
#endif //UNICODE
return status==0 && S_ISREG(buffer.st_mode);
#elif defined WINDOWS
if (File_Name.find(__T('*'))!=std::string::npos || (File_Name.find(__T("\\\\?\\"))!=0 && File_Name.find(__T('?'))!=std::string::npos) || (File_Name.find(__T("\\\\?\\"))==0 && File_Name.find(__T('?'), 4)!=std::string::npos))
return false;
#ifdef UNICODE
DWORD FileAttributes;
#ifndef ZENLIB_NO_WIN9X_SUPPORT
if (IsWin9X_Fast())
FileAttributes=GetFileAttributesA(File_Name.To_Local().c_str());
else
#endif //ZENLIB_NO_WIN9X_SUPPORT
FileAttributes=GetFileAttributesW(File_Name.c_str());
#else
DWORD FileAttributes=GetFileAttributes(File_Name.c_str());
#endif //UNICODE
return ((FileAttributes!=INVALID_FILE_ATTRIBUTES) && !(FileAttributes&FILE_ATTRIBUTE_DIRECTORY));
#endif
#endif //ZENLIB_USEWX
}
示例5: Move
//---------------------------------------------------------------------------
bool File::Move(const Ztring &Source, const Ztring &Destination, bool OverWrite)
{
if (OverWrite && Exists(Source))
Delete(Destination);
#ifdef ZENLIB_USEWX
if (OverWrite && Exists(Destination))
wxRemoveFile(Destination.c_str());
return wxRenameFile(Source.c_str(), Destination.c_str());
#else //ZENLIB_USEWX
#ifdef ZENLIB_STANDARD
return !std::rename(Source.To_Local().c_str(), Destination.To_Local().c_str());
#elif defined WINDOWS
#ifdef UNICODE
#ifndef ZENLIB_NO_WIN9X_SUPPORT
if (IsWin9X_Fast())
return MoveFileA(Source.To_Local().c_str(), Destination.To_Local().c_str())!=0;
else
#endif //ZENLIB_NO_WIN9X_SUPPORT
return MoveFileW(Source.c_str(), Destination.c_str())!=0;
#else
return MoveFile(Source.c_str(), Destination.c_str())!=0;
#endif //UNICODE
#endif
#endif //ZENLIB_USEWX
}
示例6: Open
//---------------------------------------------------------------------------
int HTTP_Client::Open (Ztring Url)
{
if (Handle)
Close();
//init
Handle=HTTPClientOpenRequest(0);
//Mehtod
if (HTTPClientSetVerb(Handle, VerbGet)!=0)
{
Close();
return 0;
}
//Send request
if (HTTPClientSendRequest(Handle, (char*)(Url.To_Local().c_str()), NULL, 0, FALSE, 0, 0)!=0)
{
Close();
return 0;
}
//Receive response
if (HTTPClientRecvResponse(Handle, 3)!=0)
{
Close();
return 0;
}
return 1;
}
示例7: Copy
//---------------------------------------------------------------------------
bool File::Copy(const Ztring &Source, const Ztring &Destination, bool OverWrite)
{
#ifdef ZENLIB_USEWX
return wxCopyFile(Source.c_str(), Destination.c_str(), OverWrite);
#else //ZENLIB_USEWX
#ifdef ZENLIB_STANDARD
return false;
#elif defined WINDOWS
#ifdef UNICODE
if (IsWin9X())
return CopyFileA(Source.To_Local().c_str(), Destination.To_Local().c_str(), !OverWrite)!=0;
else
return CopyFileW(Source.c_str(), Destination.c_str(), !OverWrite)!=0;
#else
return CopyFile(Source.c_str(), Destination.c_str(), !OverWrite)!=0;
#endif //UNICODE
#endif
#endif //ZENLIB_USEWX
}
示例8: Create
//---------------------------------------------------------------------------
bool Dir::Create(const Ztring &File_Name)
{
#ifdef ZENLIB_USEWX
return wxFileName::Mkdir(File_Name.c_str());
#else //ZENLIB_USEWX
#ifdef WINDOWS
#ifdef UNICODE
if (IsWin9X())
return CreateDirectoryA(File_Name.To_Local().c_str(), NULL)!=0;
else
return CreateDirectoryW(File_Name.c_str(), NULL)!=0;
#else
return CreateDirectory(File_Name.c_str(), NULL)!=0;
#endif //UNICODE
#else //WINDOWS
return mkdir(File_Name.To_Local().c_str(), 0700)==0;
#endif //WINDOWS
#endif //ZENLIB_USEWX
}
示例9: Delete
//---------------------------------------------------------------------------
bool File::Delete(const Ztring &File_Name)
{
#ifdef ZENLIB_USEWX
return wxRemoveFile(File_Name.c_str());
#else //ZENLIB_USEWX
#ifdef ZENLIB_STANDARD
#ifdef UNICODE
return remove(File_Name.To_Local().c_str())==0;
#else
return remove(File_Name.c_str())==0;
#endif //UNICODE
#elif defined WINDOWS
#ifdef UNICODE
if (IsWin9X())
return DeleteFileA(File_Name.To_Local().c_str())!=0;
else
return DeleteFileW(File_Name.c_str())!=0;
#else
return DeleteFile(File_Name.c_str())!=0;
#endif //UNICODE
#endif
#endif //ZENLIB_USEWX
}
示例10: Shell_Execute
void Shell_Execute(const Ztring &ToExecute)
{
#ifdef ZENLIB_USEWX
#else //ZENLIB_USEWX
#ifdef WINDOWS
#ifdef UNICODE
if (IsWin9X())
ShellExecuteA(NULL, "open", ToExecute.To_Local().c_str(), NULL, NULL, 0);
else
ShellExecute (NULL, _T("open"), ToExecute.c_str(), NULL, NULL, 0);
#else
ShellExecute(NULL, _T("open"), ToExecute.c_str(), NULL, NULL, 0);
#endif
#else
//Not supported
#endif
#endif //ZENLIB_USEWX
}
示例11: ShowOpenFolder_CallbackProc
int __stdcall ShowOpenFolder_CallbackProc (HWND hwnd, UINT uMsg, LPARAM, LPARAM)
{
if (uMsg==BFFM_INITIALIZED)
{
if (IsWin9X())
{
SetWindowTextA (hwnd, Directory_Select_Caption.To_Local().c_str()); // Caption
SendMessageA (hwnd, BFFM_ENABLEOK, 0, TRUE);
SendMessageA (hwnd, BFFM_SETSELECTION, true, (LPARAM)&InitDirA);
}
else
{
SetWindowText (hwnd, Directory_Select_Caption.c_str()); // Caption
SendMessage (hwnd, BFFM_ENABLEOK, 0, TRUE);
SendMessage (hwnd, BFFM_SETSELECTION, true, (LPARAM)&InitDir);
}
}
return 0;
}
示例12: Create
//---------------------------------------------------------------------------
bool File::Create (const Ztring &File_Name, bool OverWrite)
{
#ifdef ZENLIB_USEWX
File_Handle=(void*)new wxFile();
if (((wxFile*)File_Handle)->Create(File_Name.c_str(), OverWrite)==0)
{
//Sometime the file is locked for few milliseconds, we try again later
wxMilliSleep(3000);
if (((wxFile*)File_Handle)->Create(File_Name.c_str(), OverWrite)==0)
//File is not openable
return false;
}
return true;
#else //ZENLIB_USEWX
#ifdef ZENLIB_STANDARD
/*
int access;
switch (OverWrite)
{
case false : access=O_BINARY|O_CREAT|O_WRONLY|O_EXCL ; break;
default : access=O_BINARY|O_CREAT|O_WRONLY|O_TRUNC; break;
}
#ifdef UNICODE
File_Handle=open(File_Name.To_Local().c_str(), access);
#else
File_Handle=open(File_Name.c_str(), access);
#endif //UNICODE
return File_Handle!=-1;
*/
/*ios_base::openmode mode;
switch (OverWrite)
{
//case false : mode= ; break;
default : mode=0 ; break;
}*/
ios_base::openmode access;
switch (OverWrite)
{
case false : if (Exists(File_Name))
return false;
default : access=ios_base::binary|ios_base::in|ios_base::out|ios_base::trunc; break;
}
#ifdef UNICODE
File_Handle=new fstream(File_Name.To_Local().c_str(), access);
#else
File_Handle=new fstream(File_Name.c_str(), access);
#endif //UNICODE
return ((fstream*)File_Handle)->is_open();
#elif defined WINDOWS
DWORD dwDesiredAccess, dwShareMode, dwCreationDisposition;
switch (OverWrite)
{
case false : dwDesiredAccess=GENERIC_WRITE; dwShareMode=0; dwCreationDisposition=CREATE_NEW; break;
default : dwDesiredAccess=GENERIC_WRITE; dwShareMode=0; dwCreationDisposition=CREATE_ALWAYS; break;
}
#ifdef UNICODE
if (IsWin9X())
File_Handle=CreateFileA(File_Name.To_Local().c_str(), dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, 0, NULL);
else
File_Handle=CreateFileW(File_Name.c_str(), dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, 0, NULL);
#else
File_Handle=CreateFile(File_Name.c_str(), dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, 0, NULL);
#endif //UNICODE
if (File_Handle==INVALID_HANDLE_VALUE)
{
//Sometime the file is locked for few milliseconds, we try again later
Sleep(3000);
#ifdef UNICODE
if (IsWin9X())
File_Handle=CreateFileA(File_Name.To_Local().c_str(), dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, 0, NULL);
else
File_Handle=CreateFileW(File_Name.c_str(), dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, 0, NULL);
#else
File_Handle=CreateFile(File_Name.c_str(), dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, 0, NULL);
#endif //UNICODE
}
if (File_Handle==INVALID_HANDLE_VALUE)
//File is not openable
return false;
return true;
#endif
#endif //ZENLIB_USEWX
}
示例13: contextMenuEvent
//---------------------------------------------------------------------------
void GUI_Main_Core_Table::contextMenuEvent (QContextMenuEvent* Event)
{
//Retrieving data
QTableWidgetItem* Item=itemAt(Event->pos());
if (Item==NULL)
return;
string FileName=FileName_Before+item(Item->row(), 0)->text().toLocal8Bit().data();
string Field=horizontalHeaderItem(Item->column())->text().toLocal8Bit().data();
ZtringList History; History.Write(C->History(FileName, Field));
Ztring Date;
if (Field=="OriginationDate" || Field=="OriginationTime" || Field=="ICRD")
{
Date=C->FileDate_Get(FileName);
if (Date.size()>=10+1+8)
{
if (Date.size()>=10+1+8)
Date.resize(10+1+8);
if (Field=="ICRD")
Date.insert(0, "&Set ICRD to file creation timestamp ("); //If you change this, change at the end of method too
else
Date.insert(0, "&Set originationDate and Time to file creation timestamp ("); //If you change this, change at the end of method too
Date.append(")");
}
else
Date.clear();
}
//Creating menu
QMenu menu(this);
//Handling AllFiles display
{
menu.addAction(new QAction("Fill all open files with this field value", this)); //If you change this, change the test text too
menu.addSeparator();
}
//Handling Clear display
if (!item(Item->row(), Item->column())->text().isEmpty() && C->IsValid(FileName, Field, string()))
{
menu.addAction(new QAction("Clear this value", this)); //If you change this, change the test text too
menu.addSeparator();
}
//Handling date display
if (!Date.empty())
{
menu.addAction(new QAction(QString().fromUtf8(Date.To_Local().c_str()), this));
menu.addSeparator();
}
//Handling history display
size_t Pos=History.size();
if (!History.empty())
do
{
Pos--;
QString Text=QString().fromUtf8(History[Pos].To_Local().c_str());
if (!Text.isEmpty())
{
QAction* Action=new QAction(Text, this);
menu.addAction(Action);
}
}
while (Pos>0);
//Displaying
QAction* Action=menu.exec(Event->globalPos());
if (Action==NULL)
return;
//Retrieving data
QString Text=Action->text();
//Special cases
if (Text=="Fill all open files with this field value") //If you change this, change the creation text too
{
for (int Row=0; Row<rowCount(); Row++)
{
item(Row, Item->column())->setText(QString().fromUtf8(Ztring(C->Get(FileName, Field)).To_Local().c_str()));
dataChanged(indexFromItem(item(Row, Item->column())), indexFromItem(item(Row, Item->column())));
//Special cases
if (Field=="UMID" || Field=="LoudnessValue" || Field=="LoudnessRange" || Field=="MaxTruePeakLevel" || Field=="MaxMomentaryLoudness" || Field=="MaxShortTermLoudness")
{
//Changing BextVersion Enabled value
SetText (*Item, "BextVersion");
SetEnabled(*Item, "BextVersion");
}
}
return;
}
if (Text=="Clear this value") //If you change this, change the creation text too
Text.clear();
//Filling
if (Text.contains("&Set ")) //If you change this, change the creation text too
{
//.........这里部分代码省略.........