Ejemplo n.º 1
0
/***************************************************************************
 *      bindBuiltinVariable
 ***************************************************************************/
bool CCilVm::bindBuiltinVariable( const wstring& strQualifiedName,
                                  CVariable* const pvar )
{
    bool bReturn = true;

    //Bind the var

    if( strQualifiedName.find( STRING_INTERNAL_SCOPEDELIMITER ) != wstring::npos )
    {
        wstring strRoot = strQualifiedName.substr( 0, strQualifiedName.rfind( STRING_INTERNAL_SCOPEDELIMITER ) );
        assert( strRoot.find( STRING_INTERNAL_SCOPEDELIMITER ) == wstring::npos );

        wstring strLeaf = strQualifiedName.substr( strQualifiedName.rfind( STRING_INTERNAL_SCOPEDELIMITER ) + 1,
                          strQualifiedName.length() );
        RID ridObject = getMetaData().queryBuiltinObjectRid( strRoot );
        if( ridObject == RID_NOTDEFINED )
            return false;

        //Create property
        getPrototypeObject( ridObject ).setProperty( strLeaf,
                *pvar );
    }

    return bReturn;
}
Ejemplo n.º 2
0
wstring CStaticPubFunc::GetFileExtendName(wstring strFileName)
{
	int intCharPosition;

	//Find "\\",Get The File's Name
	intCharPosition = strFileName.rfind(L'\\');
	if(-1 != intCharPosition)
	{
		strFileName = strFileName.substr(intCharPosition - 1);
	}
	//AfxMessageBox(strFileName);

	//Find ".",Get the file's extend name
	intCharPosition = strFileName.rfind(L'.');
	if(-1 != intCharPosition)
	{
		strFileName = strFileName.substr(intCharPosition - 1);
		return strFileName;
	}
	else
	{
		//No extend name
		return L"";
	}
}
Ejemplo n.º 3
0
wstring getNameFromSoundString(wstring sSoundString)
{
	size_t end = sSoundString.rfind(TEXT(".flac"));
	size_t start = sSoundString.rfind('.', end-1);
	if(start == wstring::npos || end == wstring::npos)	//Not any numbers heres
		return sSoundString;
	sSoundString.erase(start, end-start);	//Erase the numbers in the middle
	return sSoundString;	//Done
}
Ejemplo n.º 4
0
 CTaskInfo::CTaskInfo(wstring filePath)
 {
 	m_Index = 0;
 	m_strFilePath = filePath;
 	int nPos = filePath.rfind('.');
 	m_strFileExtent = filePath.substr(nPos);
 	nPos = filePath.rfind('\\');
 	m_strFileName = filePath.substr(nPos+1);
 	m_strFileNameWithoutExt = m_strFileName.substr(0,m_strFileName.find('.'));
 	wstring strFileExtent = _tcslwr((wchar_t*)m_strFileExtent.c_str());
 //	map<wstring,int>::iterator Iter = theApp.m_pConfig->m_MapFileType.find(strFileExtent);
 // 	if (Iter!=theApp.m_pConfig->m_MapFileType.end())
 // 	{
 // 		//说明找到
 // 		m_nFileType = theApp.m_pConfig->m_MapFileType[m_strFileExtent];
 // 	}
 // 	else
 // 	{
 // 		g_Logger.Debug(__FILE__,__LINE__,_T("没有对应的文件类型%s"),m_strFileExtent.c_str());
 // 	}
 // 	if (_tcsicmp(m_strFileExtent.c_str(),_T(".doc")) ==0)
 // 	{
 // 		m_nFileType = FILETYPE_DOC;
 // 	}
 // 	else if(_tcsicmp(m_strFileExtent.c_str(),_T(".docx")) ==0)
 // 	{
 // 		m_nFileType = FILETYPE_DOCX;
 // 
 // 	}
 // 	else if(_tcsicmp(m_strFileExtent.c_str(),_T(".wps")) ==0)
 // 	{
 // 		m_nFileType = FILETYPE_WPS;
 // 	}
 // 	else if(_tcsicmp(m_strFileExtent.c_str(),_T(".xls")) ==0)
 // 	{
 // 		m_nFileType = FILETYPE_XLS;
 // 	}
 // 	else if(_tcsicmp(m_strFileExtent.c_str(),_T(".xlt")) ==0)
 // 	{
 // 		m_nFileType = FILETYPE_XLT;
 // 	}
 // 	else if(_tcsicmp(m_strFileExtent.c_str(),_T(".xlsx")) ==0)
 // 	{
 // 		m_nFileType = FILETYPE_XLSX;
 // 	}
 // 	else if(_tcsicmp(m_strFileExtent.c_str(),_T(".et")) ==0)
 // 	{
 // 		m_nFileType = FILETYPE_ET;
 // 	}
 }
Ejemplo n.º 5
0
/***************************************************************************
 *      bindBuiltinMethod
 ***************************************************************************/
bool CCilVm::bindBuiltinMethod( const wstring& strQualifiedName,
                                PMETHOD const pMethod,
                                const int32_t iLength )
{
    bool bReturn = true;
    RID ridMethod = getMetaData().queryBuiltinMethodRid( strQualifiedName );
    if( ridMethod == RID_NULL )
        return false;

    //Bind the API
    METHOD_DEF& method = getMetaData().getMethod( ridMethod );
    if( method.MethodType != METHOD_NATIVE )
        return false;
    method.lpFunction = pMethod;

    if( strQualifiedName.find( STRING_INTERNAL_SCOPEDELIMITER ) != wstring::npos )
    {
        wstring strRoot = strQualifiedName.substr( 0, strQualifiedName.rfind( STRING_INTERNAL_SCOPEDELIMITER ) );
        assert( strRoot.find( STRING_INTERNAL_SCOPEDELIMITER ) == wstring::npos );

        wstring strLeaf = strQualifiedName.substr( strQualifiedName.rfind( STRING_INTERNAL_SCOPEDELIMITER ) + 1,
                          strQualifiedName.length() );
        RID ridObject = getMetaData().queryBuiltinObjectRid( strRoot );
        if( ridObject == RID_NOTDEFINED )
            return false;

        //Create property
        getPrototypeObject( ridObject ).setProperty( this,
                strLeaf,
                ridMethod,
                iLength );
    }
    else
    {
        //Global method
        //e.g. print, eval etc
        //Those one need to have correspond static field to keep properties
        CG_SYMBOL_INFORMATION& info = querySymbolInformation( strQualifiedName + STRING_OBJECTNAME_POSTFIX );
        assert( info.Flags == CG_SYMBOL_FLAG_GLOBAL );

        RID rid = info.rid;
        assert( rid != RID_NOTDEFINED );
        if( rid )
            setStaticFieldFunctionObject( rid, ridMethod );
    }

    return bReturn;
}
Ejemplo n.º 6
0
void NormalizeDirPathPrefix(wstring & dirPath)
{
	if (dirPath.empty())
		return;
	if (dirPath.rfind(wchar_t(kDirDelimiter)) != dirPath.length() - 1)
		dirPath += wchar_t(kDirDelimiter);
}
Ejemplo n.º 7
0
bool str_endswith(const wstring &s, const wstring &sfx) {
	size_t p = s.rfind(sfx);
	if (p != string::npos) {
		if (p == (s.length() - sfx.length())) return true;
	}
	return false;
}
/*
	This method loads all the sprite types found in the provided sprite type list file
	into the game state manager, including their images.
*/
bool PoseurSpriteTypesImporter::loadSpriteTypes(Game *game, wstring spriteTypesListFileName)
{
	int slashIndex = spriteTypesListFileName.rfind('/');
	dir = string(spriteTypesListFileName.begin(), spriteTypesListFileName.end()).substr(0, slashIndex+1);
	const char *spriteTypesListFile = newCharArrayFromWstring(spriteTypesListFileName);
	bool success = loadSpriteTypesListInfo(spriteTypesListFile);
	if (!success) return false;
	for (unsigned int i = 0; i < spriteTypes.size(); i++)
	{
		success = loadSpriteTypeInfo(spriteTypes[i]);
		if (!success) return false;
	}

	TextureManager *tm = game->getGraphics()->getWorldTextureManager();
	WStringTable *wStringTable = tm->getWStringTable();

	// NOW LET'S USE ALL THE INFO WE'VE LOADED 
	// LET'S START BY LOADING THE TEXTURES INTO THE WORLD TEXTURE MANAGER
	for (unsigned int i = 0; i < spriteTypes.size(); i++)
	{
		string spriteType = spriteTypes[i];
		unsigned int offset = wStringTable->getNumWStringsInTable();
		map<int, string> images = spriteTypesImages[spriteType];
		for (int j = 0; j < images.size(); j++)
		{
			string imageToLoad = images[j];
			wstring wImageToLoad(imageToLoad.begin(), imageToLoad.end());
			tm->loadTexture(wImageToLoad);
		}

		AnimatedSpriteType *ast = new AnimatedSpriteType();
		unsigned int spriteTypeId = game->getGSM()->getSpriteManager()->addSpriteType(ast);
		ast->setSpriteTypeID(spriteTypeId);
		Dimensions dim = spriteTypesDimensions[spriteType];
		ast->setTextureSize(dim.width, dim.height);
		
		map<string, vector<Pose>> animations = spriteTypesAnimationsLists[spriteType];
		map<string, vector<Pose>>::iterator it = animations.begin();
		while (it != animations.end())
		{
			string key = it->first;
			wstring wKey(key.begin(), key.end());
			ast->addAnimationSequence(wKey);
			vector<Pose> poseList = it->second;
			vector<Pose>::iterator poseIt = poseList.begin();
			while (poseIt != poseList.end())
			{
				Pose pose = *poseIt;
				ast->addAnimationFrame(wKey, pose.imageId + offset - 1, pose.duration);
				poseIt++;
			}				
			it++;
		}
	}


	return true;
}
Ejemplo n.º 9
0
HRESULT GetFilePathExt(const wstring & path, wstring & ext)
{
	int dotPos = path.rfind(L'.');
	if (dotPos >= 0) {
		ext = path.substr(dotPos + 1);
		return S_OK;
	}

	return E_FAIL;
}
Ejemplo n.º 10
0
wstring CrabStringFindWholeWord(const wstring &t, size_t pos, const wstring &BreakupMark, const wstring &BreakupMarkOnceMore)
{
    wstring foundstr;
    if(0==pos) {
        wstring strR = t;
        size_t foundposL = 0;
        size_t foundposR = t.find(BreakupMark);
        if(BreakupMarkOnceMore.length()>0){ // <added><20150615><dzliu> use another BreakupMarkOnceMore
            if(wstring::npos==foundposR){foundposR = strR.find(BreakupMarkOnceMore);}else{
                if(strR.find(BreakupMarkOnceMore)<foundposR){foundposR=strR.find(BreakupMarkOnceMore);}
            }
        }
        if(wstring::npos==foundposR){foundposR=t.length()-1;}else{
            foundposR=foundposR-1;
        }
        foundstr = t.substr(foundposL,foundposR-foundposL+1);
    } else if(t.length()-1==pos) {
        wstring strL = t;
        size_t foundposL = t.rfind(BreakupMark);
        if(BreakupMarkOnceMore.length()>0){ // <added><20150615><dzliu> use another BreakupMarkOnceMore
            if(wstring::npos==foundposL){foundposL = strL.rfind(BreakupMarkOnceMore);}else{
                if(strL.rfind(BreakupMarkOnceMore)>foundposL){foundposL=strL.rfind(BreakupMarkOnceMore);}
            }
        }
        if(wstring::npos==foundposL){foundposL=0;}else{
            foundposL=foundposL+1;
        }
        size_t foundposR = t.length()-1;
        foundstr = t.substr(foundposL,foundposR-foundposL+1);
    } else if(0<pos && t.length()-1>pos) {
        wstring strL = t.substr(0,pos);
        wstring strR = t.substr(pos);
        size_t foundposL = strL.rfind(BreakupMark);
        if(BreakupMarkOnceMore.length()>0){ // <added><20150615><dzliu> use another BreakupMarkOnceMore
            if(wstring::npos==foundposL){foundposL = strL.rfind(BreakupMarkOnceMore);}else{
                if(strL.rfind(BreakupMarkOnceMore)>foundposL){foundposL=strL.rfind(BreakupMarkOnceMore);}
            }
        }
        if(wstring::npos==foundposL){foundposL=0;}else{
            foundposL=foundposL+1;
        }
        size_t foundposR = strR.find(BreakupMark);
        if(BreakupMarkOnceMore.length()>0){ // <added><20150615><dzliu> use another BreakupMarkOnceMore
            if(wstring::npos==foundposR){foundposR = strR.find(BreakupMarkOnceMore);}else{
                if(strR.find(BreakupMarkOnceMore)<foundposR){foundposR=strR.find(BreakupMarkOnceMore);}
            }
        }
        if(wstring::npos==foundposR){foundposR=t.length()-1;}else{
            foundposR=foundposR-1+pos;
        }
        foundstr = t.substr(foundposL,foundposR-foundposL+1);
    }
    return foundstr;
}
Ejemplo n.º 11
0
void CAvi2Flv::InsertMediaInfo(const wstring &strIn, const wstring& strOut)
{
	AVIFILEINFO aviInfo = CAviHelper::AVI_GetFileInfo(strIn);
	//转码成功后插数据库
	DVRMEDIA_INFO mi;
	CString strT;
	strT.Format(_T("%d"), aviInfo.dwWidth);
	mi.strViewWidth = strT.GetString();
	strT.Format(_T("%d"), aviInfo.dwHeight);
	mi.strViewHeight = strT.GetString();
	wstring strPath = strIn.substr( SHAREDATA.g_strFilePath.GetLength() + 1);
	wstring str = strPath.substr(0, strPath.find(_T("\\")) );
	mi.strDvrNumber = str;

	CTime tm = CTime::GetCurrentTime();
	mi.strDataUploadTime = tm.Format(_T("%Y-%m-%d %H:%M:%S"));
	mi.strDataIp = SHAREDATA.g_pMainFrame->GetIpAddr().c_str();
	mi.strFileName = strIn.substr(strIn.rfind(_T("\\")) + 1);

	CFile localFile;
	if(!localFile.Open(strIn.c_str(), CFile::modeRead|CFile::shareDenyNone))
	{
		strT.Format(_T("%s"), 0);
	}
	else
	{
		strT.Format(_T("%d"), localFile.GetLength());
		localFile.Close();
	}
	mi.strFileSize = strT;

	mi.strFileType = _T("AVI");
	strT.Format(_T("%d"), aviInfo.dwRate / aviInfo.dwScale);
	mi.strFrameRate = strT;

	//wstring sFtpip, sFtpport, sIISip, sIISport;
	//bool bRlt = DB.QueryIpPortByDevId(SHAREDATA.g_strDeviceId.GetString(), sFtpip, sFtpport, sIISip, sIISport);

	strPath = strOut.substr(SHAREDATA.g_strFilePath.GetLength() + 1);
	mi.strFtpFileUrl = strPath; //_T("ftp://") + sFtpip + _T(":") + sFtpport  + _T("//") +  strPath;
	mi.strIISFileUrl = strPath; //_T("http://") + sIISip + _T(":") + sIISport + _T("//") + strPath;
	mi.strLocateFilePath = strIn.c_str();
	strT.Format(_T("%d"), aviInfo.dwRate / aviInfo.dwScale * aviInfo.dwLength);
	mi.strMediaDuration = strT;	//毫秒

	mi.strMediaStartTime = GetStartTime(strIn);
	mi.strMediaEndTime = AddTime(mi.strMediaStartTime, mi.strMediaDuration);
	mi.strRecordTime = mi.strMediaStartTime;

	mi.strRemark = _T(" ");
	mi.strVideoType = _T("AVI");

	DB.InsertMediaInfo(mi);
}
Ejemplo n.º 12
0
vector<wstring> StringUtils::splitLast(const wstring& wstr, const wstring& stuff)
{
	vector<wstring> strList;
	int pos = wstr.rfind(stuff);
	if (-1 != pos){
		strList.push_back(wstr.substr(0,pos));
		strList.push_back(wstr.substr(pos+1, wstr.length()));

	}
	strList.push_back(wstr);
	return strList;
}
Ejemplo n.º 13
0
BOOL checkTXT(wstring stri)
{
	wstring types[3] = { L".txt", L".cfg", L".hoshou" };

	for (int t = 0; t < 3; t++)
	{
		if(stri.rfind(types[t]) != string::npos)
			return TRUE;
	}

	return FALSE;
}
Ejemplo n.º 14
0
wstring extract_file_path(const wstring& path) {
  size_t pos = path.rfind(L'\\');
  if (pos == wstring::npos) {
    pos = 0;
  }
  size_t path_root_len;
  bool is_unc_path;
  locate_path_root(path, path_root_len, is_unc_path);
  if ((pos <= path_root_len) && (path_root_len != 0))
    return path.substr(0, path_root_len).append(1, L'\\');
  else
    return path.substr(0, pos);
}
Ejemplo n.º 15
0
wstring extract_file_ext(const wstring& path) {
  size_t ext_pos = path.rfind(L'.');
  if (ext_pos == wstring::npos) {
    return wstring();
  }
  size_t name_pos = path.rfind(L'\\');
  if (name_pos == wstring::npos) {
    name_pos = 0;
  }
  else {
    name_pos++;
  }
  if (ext_pos <= name_pos)
    return wstring();
  size_t path_root_len;
  bool is_unc_path;
  locate_path_root(path, path_root_len, is_unc_path);
  if ((ext_pos <= path_root_len) && (path_root_len != 0))
    return wstring();
  else
    return path.substr(ext_pos);
}
Ejemplo n.º 16
0
// getInterfaceNamesFromNetshOutput() function is used to get interface names from string like below:
//
// Admin State    State          Type             Interface Name
// -------------------------------------------------------------------------
// Enabled        Connected      Dedicated        VMware Network Adapter VMnet1
// Enabled        Connected      Dedicated        VMware Network Adapter VMnet8
// Enabled        Connected      Dedicated        VMware Network Adapter VMnet2
// Enabled        Connected      Dedicated        VMware Network Adapter VMnet3
// Enabled        Connected      Dedicated        Wi-Fi
// Disabled       Disconnected   Dedicated        Ethernet
// Enabled        Connected      Dedicated        Npcap Loopback Adapter
//
vector<wstring> getInterfaceNamesFromNetshOutput(wstring strOutput)
{
	vector<wstring> nResults;
	size_t iLineStart;
	size_t iLineEnd = 0;
	size_t iStringStart;
	size_t iStringEnd;

	while (iLineEnd < strOutput.length() && strOutput[iLineEnd] == L'\n')
	{
		iLineEnd ++;
	}

	iLineEnd = strOutput.find(L'\n', iLineEnd);
	if (iLineEnd == wstring::npos)
	{
		return nResults;
	}
	iLineEnd ++;

	iLineEnd = strOutput.find(L'\n', iLineEnd);
	if (iLineEnd == wstring::npos)
	{
		return nResults;
	}

	iLineEnd ++;
	iLineStart = iLineEnd;

	while ((iLineEnd = strOutput.find(L'\n', iLineEnd)) != wstring::npos)
	{
		iStringEnd = iLineEnd;
		iStringStart = strOutput.rfind(L"    ", iLineEnd);
		if (iStringStart < iLineStart)
		{
			return nResults;
		}
		else
		{
			iStringStart += wcslen(L"    ");
		}

		wstring strInterfaceName = strOutput.substr(iStringStart, iStringEnd - iStringStart);
		nResults.push_back(strInterfaceName);

		iLineEnd ++;
		iLineStart = iLineEnd;
	}

	return nResults;
}
Ejemplo n.º 17
0
wstring
RegistryMonitor::convertRegistryObjectNameToHiveName(wstring registryObjectName)
{	
	/* Convert /Registry/Machine etc to the actual hive name like HKLM */
	std::list<ObjectPair>::iterator it;
	for(it = objectNameMap.begin(); it != objectNameMap.end(); it++)
	{
		size_t position = registryObjectName.rfind(it->first,0);
		if(position != wstring::npos)
		{
			return registryObjectName.replace(position, it->first.length(), it->second, 0, it->second.length());
		}
	}
	return registryObjectName;
}
Ejemplo n.º 18
0
/***************************************************************************
 *      BindBuiltinMethodWithWrapper
 ***************************************************************************/
bool CCilVm::bindBuiltinMethod( const wstring& strQualifiedName,
                                PMETHOD const pMethod,
                                PMETHOD const pMethodBody )
{
    bool bReturn = true;
    RID ridMethod = getMetaData().queryBuiltinMethodRid( strQualifiedName );
    if( ridMethod == RID_NULL )
        return false;

    //Bind the API
    METHOD_DEF& method = getMetaData().getMethod( ridMethod );
    if( method.MethodType != METHOD_WRAPPED )
        return false;
    method.lpFunction = pMethod;
    method.lpFunctionBody = pMethodBody;

    if( strQualifiedName.find( STRING_INTERNAL_SCOPEDELIMITER ) != wstring::npos )
    {
        wstring strRoot = strQualifiedName.substr( 0, strQualifiedName.rfind( STRING_INTERNAL_SCOPEDELIMITER ) );
        assert( strRoot.find( STRING_INTERNAL_SCOPEDELIMITER ) == wstring::npos );

        wstring strLeaf = strQualifiedName.substr( strQualifiedName.rfind( STRING_INTERNAL_SCOPEDELIMITER ) + 1,
                          strQualifiedName.length() );
        RID ridObject = getMetaData().queryBuiltinObjectRid( strRoot );
        if( ridObject == RID_NOTDEFINED )
            return false;

        //Create property
        getPrototypeObject( ridObject ).setProperty( this,
                strLeaf,
                ridMethod,
                method.iNumArgments );
    }

    return bReturn;
}
Ejemplo n.º 19
0
wstring 
FileMonitor::convertFileObjectNameToDosName(wstring fileObjectName)
{
	stdext::hash_map<wstring, wstring>::iterator it;
	for(it = dosNameMap.begin(); it != dosNameMap.end(); it++)
	{
		size_t position = fileObjectName.rfind(it->first,0);
		if(position != wstring::npos)
		{
			fileObjectName.replace(position, it->first.length(), it->second, 0, it->second.length());
			break;
		}
	}
	//transform(fileObjectName.begin(), fileObjectName.end(), fileObjectName.begin(), tolower);
	return fileObjectName;
}
Ejemplo n.º 20
0
static const wstring& exePath()
{
    static wstring path;
    static bool initialized;

    if (initialized)
        return path;
    initialized = true;

    TCHAR buffer[MAX_PATH];
    GetModuleFileName(GetModuleHandle(0), buffer, ARRAYSIZE(buffer));
    path = buffer;
    int lastSlash = path.rfind('\\');
    if (lastSlash != -1 && lastSlash + 1 < path.length())
        path = path.substr(0, lastSlash + 1);

    return path;
}
Ejemplo n.º 21
0
static bool split(const wstring& s, wstring &path)
{
	bool bResult = false;
	vector<wstring> output;

	wstring::size_type prev_pos = 0, pos = 0;

	while((pos = s.find(L';', pos)) != wstring::npos)
	{
		wstring substring( s.substr(prev_pos, pos-prev_pos) );
		if (substring.find(L"Power Gadget 2.") != wstring::npos)
		{
			path = substring;
			bResult = true;
			break;
		}
		prev_pos = ++pos;
	}

	if (!bResult)
	{
		wstring substring(s.substr(prev_pos, pos-prev_pos));

		if (substring.find(L"Power Gadget 2.") != wstring::npos)
		{
			path = substring;
			bResult = true;
		}
	}	

	if (bResult)
	{
		basic_string <char>::size_type pos = path.rfind(L" ");
		wstring version = path.substr(pos+1, path.length());
		double fVer = _wtof(version.c_str());
		if (fVer > 2.6)
			bResult = true;
	}
	
	return bResult;
}
Ejemplo n.º 22
0
BOOL CTunerManager::FindBonFileName(wstring src, wstring& dllName)
{
	size_t pos = src.rfind(L')');
	if( pos == string::npos ){
		return FALSE;
	}

	int count = 1;
	for( int i=(int)pos-1; i>=0; i-- ){
		if( src[i] == L')' ){
			count++;
		}else if( src[i] == L'(' ){
			count--;
		}
		if( count == 0 ){
			dllName = src.substr(0, i);
			return TRUE;
		}
	}

	return FALSE;
}
Ejemplo n.º 23
0
int InStrRev(const wstring& str1, const wstring& str2, int pos) {
  size_t i = str1.rfind(str2, pos);
  return (i != wstring::npos) ? i : -1;
}
Ejemplo n.º 24
0
	template<> void WXML::constructProperty(wstring &str)
	{
		long i_begin = str.find(L'<' + key) + key.size() + 1;
		long i_endSlash = indexFilter(str.rfind('/'));
		long i_endBlock = indexFilter(str.find('>'));

		if (i_begin >= Math::calcMin<long>({ i_endSlash, i_endBlock }).getValue()) //WHY UINT ?
			return;

		wstring &line = WStringUtil::substring(str, i_begin, Math::calcMin<long>({ i_endSlash, i_endBlock }).getValue());
		//<comp label='ABCD' /> : " label='ABCD' "

		if (line.find('=') == wstring::npos)
			return;

		wstring label, value;
		vector<XMLQuote*> helpers;
		bool inQuote = false;
		long type;
		long startPoint, equalPoint;
		size_t i;

		for (i = 0; i < line.size(); i++) {
			//Start of quote
			if (inQuote == false && (line[i] == '\'' || line[i] == '"'))
			{
				inQuote = true;
				startPoint = i;

				if (line[i] == '\'')
					type = XMLQuote::QUOTE_SINGLE;
				else if (line[i] == '"')
					type = XMLQuote::QUOTE_DOUBLE;
			}
			else if
				(
				inQuote == true &&
				(
				(type == XMLQuote::QUOTE_SINGLE && line[i] == '\'') ||
				(type == XMLQuote::QUOTE_DOUBLE && line[i] == '"')
				)
				)
			{
				helpers.push_back(new XMLQuote(type, startPoint, i));
				inQuote = false;
			}
		}
		for (i = 0; i < helpers.size(); i++)
		{
			if (i == 0)
			{
				equalPoint = line.find('=');
				label = move(line.substr(0, equalPoint));//line.substring(0, equalPoint);
			}
			else
			{
				equalPoint = line.find('=', helpers[i - 1]->getEndPoint() + 1);
				label = move(WStringUtil::substring(line, helpers[i - 1]->getEndPoint() + 1, equalPoint));
			}
			label = move(WStringUtil::trim(label));//label.emptyRemover();
			value = move(line.substr(helpers[i]->getStartPoint() + 1, helpers[i]->getEndPoint() - (helpers[i]->getStartPoint() + 1)));
			value = move(WStringUtil::removeEmptyHTMLSpace(value));

			//insert into propertyMap
			propertyMap.set(label, value);
		}
		for (i = 0; i < helpers.size(); i++)
			delete helpers[i];
	}
Ejemplo n.º 25
0
	template<> void WXML::constructChildren(wstring &str)
	{
		if (str.find('<') == wstring::npos)
			return;

		long startX = str.find('<'), endX = str.rfind('>') + 1;
		str = move(str.substr(startX, endX - startX));

		map<wstring, queue<WXML *>> xmlQueueMap;
		queue<WXML*> *xmlQueue;
		WXML *xml;

		long blockStartCount = 0;
		long blockEndCount = 0;
		long start = 0;
		long end;
		size_t i;

		//괄호를 찾아내어 BasicXML 생성 후 임시 컨테이너에 저장
		for (i = 0; i < str.size(); i++) {
			if (str[i] == '<' && str.substr(i, 2) != L"</")
				blockStartCount++;
			else if (str.substr(i, 2) == L"/>" || str.substr(i, 2) == L"</")
				blockEndCount++;

			if (blockStartCount >= 1 && blockStartCount == blockEndCount) {
				end = str.find('>', i);

				xml = new WXML(this, str.substr(start, end + 1 - start));
				xmlQueueMap[xml->getKey()].push(xml);

				i = end; //WHY NOT END+1? 
				start = end + 1;
				blockStartCount = 0;
				blockEndCount = 0;
			}
		}

		//예약 및 설정
		for (auto it = xmlQueueMap.begin(); it != xmlQueueMap.end(); it++)
		{
			wstring key = move(it->first); //키를 받아오고
			shared_ptr<WXMLList> xmlList(new WXMLList()); //BasicXMLList를 만들며

			xmlQueue = &(it->second); //xmlQueue도 불러옴
			xmlList->reserve(xmlQueue->size()); //xmlQueue의 size에 따라 예약을 잡고

			//xmlList에 큐의 내용을 옮긴다
			while (xmlQueue->empty() == false)
			{
				xml = xmlQueue->front();
				xmlList->push_back(shared_ptr<WXML>(xml));

				xmlQueue->pop();
			}
			//Map(BasicXML : map<wstring, BasicXMLList>)에 최종적으로 입력함
			insert({ key, xmlList });
		}

		if (size() > 0)
			value.clear();
	}
Ejemplo n.º 26
0
wstring getNameForURL(const wstring &url) {
	if (url.empty())
		// Avoid pointless computation.
		return url;

	wstring::size_type colonPos = url.find(L':');
	if (colonPos != wstring::npos && url.compare(colonPos, 3, L"://") != 0) {
		// This URL specifies a protocol, but it is not a path-based protocol; e.g. it is a javascript: or mailto: URL.
		// Return the URL as is with the protocol stripped.
		return url.substr(colonPos + 1);
	}

	// The URL either specifies a path-based protocol (e.g. http://)
	// or specifies no protocol, in which case it is assumed to be a path.

	// Find the beginning of the query string.
	wstring::size_type queryStart = url.rfind(L'?');
	// Assume the query string ends at the end of the string.
	wstring::size_type queryLen = wstring::npos;

	// Find the beginning of the target anchor.
	wstring::size_type anchorStart = url.rfind(L'#');
	if (anchorStart != wstring::npos)
		// The query string ends just before the anchor begins.
		queryLen = anchorStart - queryStart - 1;

	wstring::size_type pathStart, pathEnd;
	bool stripExten = true;
	// Find the end of the path.
	if (queryStart != wstring::npos)
		pathEnd = queryStart;
	else if (anchorStart != wstring::npos)
		pathEnd = anchorStart;
	else
		pathEnd = url.length();
	// wstring::npos for pathEnd means no path.
	pathEnd = (pathEnd >= 0) ? (pathEnd - 1) : wstring::npos;

	if (pathEnd != wstring::npos && url[pathEnd] == L'/') {
		// The path ends with a '/', so go back one, as an empty path component is useless.
		pathEnd = (pathEnd >= 0) ? (pathEnd - 1) : wstring::npos;
		// This path component is not a filename, so don't strip the extension.
		stripExten = false;
	}

	if (pathEnd != wstring::npos) {
		// Find the start of this path component.
		pathStart = url.rfind(L'/', pathEnd);
		if (pathStart == wstring::npos) {
			// url is a single path component.
			pathStart = 0;
		} else {
			++pathStart;
			if (stripExten && pathStart == colonPos + 3) {
				// This URL provides a hostname and the hostname is the last path component,
				// so don't strip the extension.
				stripExten = false;
			}
		}

		if (stripExten) {
			// Strip the extension, if any.
			wstring::size_type extenStart = url.rfind(L'.', pathEnd);
			if (extenStart != wstring::npos && extenStart > pathStart)
				pathEnd = extenStart - 1;
		}
	}

	wstring name;
	if (pathEnd != wstring::npos)
		name = url.substr(pathStart, pathEnd - pathStart + 1);
	if (queryStart != wstring::npos)
		name += L' ' + url.substr(queryStart + 1, queryLen);
	if (anchorStart != wstring::npos)
		name += L' ' + url.substr(anchorStart + 1);
	return name;
}
Ejemplo n.º 27
0
// 파일명에서 경로를 얻어 반환
static wstring ExtractFilePath(wstring s) {
	int pos=s.rfind(L"\\");
	if (pos==string::npos) return L"";
	return s.substr(0, pos+1);
}