本文整理汇总了C++中CStdStringArray::at方法的典型用法代码示例。如果您正苦于以下问题:C++ CStdStringArray::at方法的具体用法?C++ CStdStringArray::at怎么用?C++ CStdStringArray::at使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CStdStringArray
的用法示例。
在下文中一共展示了CStdStringArray::at方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
TEST_F(TestURIUtils, SplitPath)
{
CStdStringArray strarray;
strarray = URIUtils::SplitPath("http://www.test.com/path/to/movie.avi");
EXPECT_STREQ("http://www.test.com/", strarray.at(0).c_str());
EXPECT_STREQ("path", strarray.at(1).c_str());
EXPECT_STREQ("to", strarray.at(2).c_str());
EXPECT_STREQ("movie.avi", strarray.at(3).c_str());
}
示例2: SplitString
vector<string> StringUtils::Split(const CStdString& input, const CStdString& delimiter, unsigned int iMaxStrings /* = 0 */)
{
CStdStringArray result;
SplitString(input, delimiter, result, iMaxStrings);
vector<string> strArray;
for (unsigned int index = 0; index < result.size(); index++)
strArray.push_back(result.at(index));
return strArray;
}
示例3: SelectAddonID
int CGUIWindowAddonBrowser::SelectAddonID(const vector<ADDON::TYPE> &types, CStdString &addonID, bool showNone /*= false*/)
{
CStdStringArray addonIDs;
if (!addonID.IsEmpty())
addonIDs.push_back(addonID);
int retval = SelectAddonID(types, addonIDs, showNone, false);
if (addonIDs.size() > 0)
addonID = addonIDs.at(0);
else
addonID = "";
return retval;
}
示例4: TranslateUrl
CStdString CVideoDatabaseFile::TranslateUrl(const CURL& url)
{
CStdString strFileName=URIUtils::GetFileName(url.Get());
if (strFileName.empty())
return "";
CStdString strPath = URIUtils::GetDirectory(url.Get());
if (strPath.empty())
return "";
CStdString strExtension = URIUtils::GetExtension(strFileName);
URIUtils::RemoveExtension(strFileName);
if (!StringUtils::IsNaturalNumber(strFileName))
return "";
long idDb=atol(strFileName.c_str());
CStdStringArray pathElem;
StringUtils::SplitString(strPath, "/", pathElem);
if (pathElem.size() == 0)
return "";
CStdString itemType = pathElem.at(2);
VIDEODB_CONTENT_TYPE type;
if (itemType.Equals("movies") || itemType.Equals("recentlyaddedmovies"))
type = VIDEODB_CONTENT_MOVIES;
else if (itemType.Equals("episodes") || itemType.Equals("recentlyaddedepisodes"))
type = VIDEODB_CONTENT_EPISODES;
else if (itemType.Equals("musicvideos") || itemType.Equals("recentlyaddedmusicvideos"))
type = VIDEODB_CONTENT_MUSICVIDEOS;
else
return "";
CVideoDatabase videoDatabase;
if (!videoDatabase.Open())
return "";
CStdString realFilename;
videoDatabase.GetFilePathById(idDb, realFilename, type);
return realFilename;
}
示例5: strHeader
bool CWebSocketV8::Handshake(const char* data, size_t length, std::string &response)
{
string strHeader(data, length);
const char *value;
HttpParser header;
if (header.addBytes(data, length) != HttpParser::Done)
{
CLog::Log(LOGINFO, "WebSocket [hybi-10]: incomplete handshake received");
return false;
}
// The request must be GET
value = header.getMethod();
if (value == NULL || strnicmp(value, WS_HTTP_METHOD, strlen(WS_HTTP_METHOD)) != 0)
{
CLog::Log(LOGINFO, "WebSocket [hybi-10]: invalid HTTP method received (GET expected)");
return false;
}
// The request must be HTTP/1.1 or higher
int pos;
if ((pos = strHeader.find(WS_HTTP_TAG)) == string::npos)
{
CLog::Log(LOGINFO, "WebSocket [hybi-10]: invalid handshake received");
return false;
}
pos += strlen(WS_HTTP_TAG);
istringstream converter(strHeader.substr(pos, strHeader.find_first_of(" \r\n\t", pos) - pos));
float fVersion;
converter >> fVersion;
if (fVersion < 1.1f)
{
CLog::Log(LOGINFO, "WebSocket [hybi-10]: invalid HTTP version %f (1.1 or higher expected)", fVersion);
return false;
}
string websocketKey, websocketProtocol;
// There must be a "Host" header
value = header.getValue("host");
if (value == NULL || strlen(value) == 0)
{
CLog::Log(LOGINFO, "WebSocket [hybi-10]: \"Host\" header missing");
return true;
}
// There must be a base64 encoded 16 byte (=> 24 byte as base64) "Sec-WebSocket-Key" header
value = header.getValue(WS_HEADER_KEY_LC);
if (value == NULL || (websocketKey = value).size() != 24)
{
CLog::Log(LOGINFO, "WebSocket [hybi-10]: invalid \"Sec-WebSocket-Key\" received");
return true;
}
// There might be a "Sec-WebSocket-Protocol" header
value = header.getValue(WS_HEADER_PROTOCOL_LC);
if (value && strlen(value) > 0)
{
CStdStringArray protocols;
StringUtils::SplitString(value, ",", protocols);
for (unsigned int index = 0; index < protocols.size(); index++)
{
if (protocols.at(index).Trim().Equals(WS_PROTOCOL_JSONRPC))
{
websocketProtocol = WS_PROTOCOL_JSONRPC;
break;
}
}
}
CHttpResponse httpResponse(HTTP::Get, HTTP::SwitchingProtocols, HTTP::Version1_1);
httpResponse.AddHeader(WS_HEADER_UPGRADE, WS_HEADER_UPGRADE_VALUE);
httpResponse.AddHeader(WS_HEADER_CONNECTION, WS_HEADER_UPGRADE);
httpResponse.AddHeader(WS_HEADER_ACCEPT, calculateKey(websocketKey));
if (!websocketProtocol.empty())
httpResponse.AddHeader(WS_HEADER_PROTOCOL, websocketProtocol);
char *responseBuffer;
int responseLength = httpResponse.Create(responseBuffer);
response = std::string(responseBuffer, responseLength);
m_state = WebSocketStateConnected;
return true;
}
示例6:
TEST(TestStringUtils, SplitString)
{
CStdStringArray varresults;
EXPECT_EQ(9, StringUtils::SplitString("a,b,c,de,,,fg,,", ",", varresults));
EXPECT_STREQ("a", varresults.at(0).c_str());
EXPECT_STREQ("b", varresults.at(1).c_str());
EXPECT_STREQ("c", varresults.at(2).c_str());
EXPECT_STREQ("de", varresults.at(3).c_str());
EXPECT_STREQ("", varresults.at(4).c_str());
EXPECT_STREQ("", varresults.at(5).c_str());
EXPECT_STREQ("fg", varresults.at(6).c_str());
EXPECT_STREQ("", varresults.at(7).c_str());
EXPECT_STREQ("", varresults.at(8).c_str());
varresults.clear();
varresults = StringUtils::SplitString("g,h,ij,k,lm,,n", ",");
EXPECT_STREQ("g", varresults.at(0).c_str());
EXPECT_STREQ("h", varresults.at(1).c_str());
EXPECT_STREQ("ij", varresults.at(2).c_str());
EXPECT_STREQ("k", varresults.at(3).c_str());
EXPECT_STREQ("lm", varresults.at(4).c_str());
EXPECT_STREQ("", varresults.at(5).c_str());
EXPECT_STREQ("n", varresults.at(6).c_str());
}
示例7: DoDrag
void CMusikSourcesCtrl::DoDrag( CMusikPropTreeItem* pItem )
{
if ( !pItem )
return;
COleDataSource datasrc;
HGLOBAL hgDrop;
DROPFILES* pDrop;
CStringList lsDraggedFiles;
POSITION pos;
CString sFile;
UINT uBuffSize = 0;
TCHAR* pszBuff;
FORMATETC etc = { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
// get a list of filenames with the currently
// selected items...
CStdStringArray files;
int nMode = pItem->GetPlaylistType();
// standard playlist dragged
if ( nMode == MUSIK_PLAYLIST_TYPE_STANDARD )
m_Library->GetStdPlaylistFns( pItem->GetPlaylistID(), files, false );
// now playing dragged..
else if ( nMode == MUSIK_SOURCES_TYPE_NOWPLAYING )
{
if ( m_Player->GetPlaylist() )
{
m_Library->BeginTransaction();
for ( size_t i = 0; i < m_Player->GetPlaylist()->GetCount(); i++ )
files.push_back( m_Player->GetPlaylist()->GetField( i, MUSIK_LIBRARY_TYPE_FILENAME ) );
m_Library->EndTransaction();
}
}
// library playlist dragged
else if ( nMode == MUSIK_SOURCES_TYPE_LIBRARY )
{
CMainFrame* pMain = (CMainFrame*)m_Parent;
if ( pMain->m_LibPlaylist )
{
m_Library->BeginTransaction();
for ( size_t i = 0; i < pMain->m_LibPlaylist->GetCount(); i++ )
files.push_back( pMain->m_LibPlaylist->GetField( i, MUSIK_LIBRARY_TYPE_FILENAME ) );
m_Library->EndTransaction();
}
}
else if ( nMode == MUSIK_PLAYLIST_TYPE_DYNAMIC )
MessageBox( "This operation is not supported yet.", "Musik", MB_ICONINFORMATION | MB_OK );
if ( !files.size() )
return;
// CStringList containing files
for ( size_t i = 0; i < files.size(); i++ )
{
lsDraggedFiles.AddTail( files.at( i ) );
uBuffSize += files.at( i ).GetLength() + 1;
}
files.clear();
// Add 1 extra for the final null char, and the size of the DROPFILES struct.
uBuffSize = sizeof(DROPFILES) + sizeof(TCHAR) * (uBuffSize + 1);
// Allocate memory from the heap for the DROPFILES struct.
hgDrop = GlobalAlloc ( GHND | GMEM_SHARE, uBuffSize );
if ( !hgDrop )
return;
pDrop = (DROPFILES*) GlobalLock ( hgDrop );
if ( !pDrop )
{
GlobalFree ( hgDrop );
return;
}
// Fill in the DROPFILES struct.
pDrop->pFiles = sizeof(DROPFILES);
// If we're compiling for Unicode, set the Unicode flag in the struct to
// indicate it contains Unicode strings.
#ifdef _UNICODE
pDrop->fWide = TRUE;
#endif;
// Copy all the filenames into memory after the end of the DROPFILES struct.
pos = lsDraggedFiles.GetHeadPosition();
pszBuff = (TCHAR*) (LPBYTE(pDrop) + sizeof(DROPFILES));
while ( pos )
{
lstrcpy ( pszBuff, (LPCTSTR) lsDraggedFiles.GetNext ( pos ) );
pszBuff = 1 + _tcschr ( pszBuff, '\0' );
//.........这里部分代码省略.........
示例8: OnDropFiles
void CMusikSourcesCtrl::OnDropFiles(HDROP hDropInfo)
{
// set cursor back to hour glass
SetCursor( LoadCursor( NULL, IDC_WAIT ) );
// see if the drag landed on an existing
// playlist, if it did, we'll append
CPoint pos;
::GetCursorPos( &pos );
ScreenToClient( &pos );
CMusikPropTreeItem* pItem = FindItem( pos );
// make sure the item isn't root
if ( pItem != NULL && pItem->IsRootLevel() )
return;
if ( pItem )
{
KillFocus();
pItem->Select( TRUE );
SetFocusedItem( pItem );
}
// dnd stuff
size_t nNumFiles;
TCHAR szNextFile [MAX_PATH];
SHFILEINFO rFileInfo;
nNumFiles = DragQueryFile ( hDropInfo, -1, NULL, 0 );
CStdStringArray files;
CStdString sTemp;
for ( size_t i = 0; i < nNumFiles; i++ )
{
if ( DragQueryFile( hDropInfo, i, szNextFile, MAX_PATH ) > 0 )
{
// get the filetype. if its a directory
// that was dropped, we'll want to
// recurse it and add all the supported
// media files...
SHGetFileInfo( szNextFile, 0, &rFileInfo, sizeof( rFileInfo ), SHGFI_ATTRIBUTES );
if ( rFileInfo.dwAttributes & SFGAO_FOLDER )
{
sTemp = szNextFile;
sTemp += "\\*.*";
m_Dir.m_Dir = sTemp;
m_Dir.m_Threaded = false;
m_Dir.m_Target = &files;
m_Dir.Run();
}
// otherwise it was just a file... add it...
else
files.push_back( szNextFile );
}
}
DragFinish( hDropInfo );
// did we actually hit an item?
if ( pItem )
{
// standard playlist
if ( pItem->GetPlaylistType() == MUSIK_PLAYLIST_TYPE_STANDARD )
m_Library->AppendStdPlaylist( pItem->GetPlaylistID(), files );
// hit now playing?
else if ( pItem->GetPlaylistType() == MUSIK_SOURCES_TYPE_NOWPLAYING )
{
m_Library->BeginTransaction();
CMusikSong song;
for ( size_t i = 0; i < files.size(); i++ )
{
// add song (if necessary)
m_Library->AddSong( files.at( i ) );
m_Library->GetSongFromFilename( files.at( i ), song );
m_Player->GetPlaylist()->Add( song );
}
m_Library->EndTransaction();
}
}
// else make a new playlist
else
{
CStdString playlist_str;
playlist_str.Format( _T( "New Playlist %d" ), m_StdPlaylists.size() );
m_Library->CreateStdPlaylist( playlist_str.c_str(), files );
LoadStdPlaylists();
}
// didn't hit an item, a new
// playlist was created, so it
// was pushed to the back of the list
if ( !pItem )
//.........这里部分代码省略.........
示例9: Dialog_Browse
PyObject* Dialog_Browse(PyObject *self, PyObject *args)
{
int browsetype = 0;
char useThumbs = false;
char useFileDirectories = false;
char enableMultiple = false;
CStdString value;
CStdStringArray valuelist;
PyObject* unicodeLine[3];
string utf8Line[3];
char *cDefault = NULL;
PyObject *result;
for (int i = 0; i < 3; i++)
unicodeLine[i] = NULL;
if (!PyArg_ParseTuple(args, (char*)"iOO|Obbsb",
&browsetype , &unicodeLine[0],
&unicodeLine[1], &unicodeLine[2],
&useThumbs, &useFileDirectories,
&cDefault, &enableMultiple))
{
return NULL;
}
for (int i = 0; i < 3; i++)
{
if (unicodeLine[i] && !PyXBMCGetUnicodeString(utf8Line[i], unicodeLine[i], i+1))
return NULL;
}
VECSOURCES *shares = g_settings.GetSourcesFromType(utf8Line[1]);
if (!shares) return NULL;
if (useFileDirectories && !utf8Line[2].size() == 0)
utf8Line[2] += "|.rar|.zip";
value = cDefault;
Py_BEGIN_ALLOW_THREADS
if (browsetype == 1)
{
if (enableMultiple)
CGUIDialogFileBrowser::ShowAndGetFileList(*shares, utf8Line[2], utf8Line[0], valuelist, 0 != useThumbs, 0 != useFileDirectories);
else
CGUIDialogFileBrowser::ShowAndGetFile(*shares, utf8Line[2], utf8Line[0], value, 0 != useThumbs, 0 != useFileDirectories);
}
else if (browsetype == 2)
{
if (enableMultiple)
CGUIDialogFileBrowser::ShowAndGetImageList(*shares, utf8Line[0], valuelist);
else
CGUIDialogFileBrowser::ShowAndGetImage(*shares, utf8Line[0], value);
}
else
CGUIDialogFileBrowser::ShowAndGetDirectory(*shares, utf8Line[0], value, browsetype != 0);
Py_END_ALLOW_THREADS
if (enableMultiple && (browsetype == 1 || browsetype == 2))
{
result = PyTuple_New(valuelist.size());
if (!result)
return NULL;
for (int i = 0; i < valuelist.size(); i++)
PyTuple_SetItem(result, i, PyString_FromString(valuelist.at(i).c_str()));
return result;
}
else
return Py_BuildValue((char*)"s", value.c_str());
}