Пример #1
0
/*!
	sakura.iniの1行を処理する.

	1行の読み込みが完了するごとに呼ばれる.
	
	@param line [in] 読み込んだ行
*/
void CProfile::ReadOneline(
	const wstring& line
)
{
	//	空行を読み飛ばす
	if( line.empty() )
		return;

	//コメント行を読みとばす
	if( 0 == line.compare( 0, 2, LTEXT("//") ))
		return;

	// セクション取得
	//	Jan. 29, 2004 genta compare使用
	if( line.compare( 0, 1, LTEXT("[") ) == 0 
			&& line.find( LTEXT("=") ) == line.npos
			&& line.find( LTEXT("]") ) == ( line.size() - 1 ) ) {
		Section Buffer;
		Buffer.strSectionName = line.substr( 1, line.size() - 1 - 1 );
		m_ProfileData.push_back( Buffer );
	}
	// エントリ取得
	else if( !m_ProfileData.empty() ) {	//最初のセクション以前の行のエントリは無視
		wstring::size_type idx = line.find( LTEXT("=") );
		if( line.npos != idx ) {
			m_ProfileData.back().mapEntries.insert( PAIR_STR_STR( line.substr(0,idx), line.substr(idx+1) ) );
		}
	}
}
Пример #2
0
void CameraWrapper::saveImage ( wstring image_name, wstring type)
{
  IMAGE_FILE_PARAMS file_par;

  file_par.pwchFileName = (wchar_t*)image_name.c_str ();
  file_par.pnImageID = NULL;
  file_par.ppcImageMem = NULL;
  file_par.nQuality = 0;

  if (type.compare(L"bmp") == 0) {
    file_par.nFileType = IS_IMG_BMP;
  }
  else if (type.compare(L"png") == 0) {
	  file_par.nFileType = IS_IMG_PNG;
  }
  else if (type.compare(L"jpg") == 0) {
	  file_par.nFileType = IS_IMG_JPG;
  }
  else if (type.compare(L"tif") == 0) {
	  file_par.nFileType = IS_IMG_TIF;
  }
	else if (type.compare(L"raw") == 0) {
	  file_par.nFileType = IS_IMG_RAW;
  }
	else {
		throw std::runtime_error ("Unsupported file format used for saving image");
	}

  int n_ret = is_ImageFile (h_cam, IS_IMAGE_FILE_CMD_SAVE, (void*)&file_par, sizeof (file_par));

  if (n_ret == -1) {
    logger << "Save image failed ..\n";
    throw std::runtime_error ("Save image failed ..\n");
  }
}
Пример #3
0
void BugsButtonEventHandler::handleButtonEvents(	Game *game, 
													wstring command)
{
	// THE USER PRESSED THE Exit BUTTON ON THE MAIN MENU,
	// SO LET'S SHUTDOWN THE ENTIRE APPLICATION
	if (command.compare(W_EXIT_COMMAND) == 0)
	{
		game->shutdown();
	}
	// THE USER PRESSED THE MOUSE BUTTON ON THE SPLASH
	// SCREEN, SO LET'S GO TO THE MAIN MENU
	else if (command.compare(W_GO_TO_MM_COMMAND) == 0)
	{
		GameStateManager *gsm = game->getGSM();
		gsm->goToMainMenu();
	}
	// THE USER PRESSED THE Start BUTTON ON THE MAIN MENU,
	// SO LET'S START THE GAME FROM THE FIRST LEVEL
	else if (command.compare(W_START_COMMAND) == 0)
	{
		game->setCurrentLevelFileName(W_LEVEL_1_NAME);
		game->startGame();
	}
	// THE USER PRESSED THE Quit BUTTON ON THE IN-GAME MENU,
	// SO LET'S UNLOAD THE LEVEL AND RETURN TO THE MAIN MENU
	else if (command.compare(W_QUIT_COMMAND) == 0)
	{
		game->quitGame();
	}
}
Пример #4
0
      /// <summary>Parses the page identifier</summary>
      /// <param name="pageid">The pageid</param>
      /// <param name="v">The associated game version</param>
      /// <returns>Normalised page ID</returns>
      /// <exception cref="Logic::InvalidValueException">Invalid pageID</exception>
      UINT  LanguageFileReader::ParsePageID(const wstring&  pageid, GameVersion&  v)
      {
         // X2: nnnn 
         if (pageid.length() <= 4)
         {
            v = GameVersion::Threat;
            return _wtoi(pageid.c_str());
         }
         // X3: NNnnnn
         else if (pageid.length() != 6)
            throw InvalidValueException(HERE, VString(L"Invalid page ID '%s'", pageid.c_str()) );

         // X3R: 30nnnn
         else if (pageid.compare(0, 2, L"30") == 0)
            v = GameVersion::Reunion;
         
         // X3TC: 35nnnn
         else if (pageid.compare(0, 2, L"35") == 0)
            v = GameVersion::TerranConflict;

         // X3AP: 38nnnn
         else if (pageid.compare(0, 2, L"38") == 0)
            v = GameVersion::AlbionPrelude;
         else
            throw InvalidValueException(HERE, VString(L"Invalid page ID '%s'", pageid.c_str()) );

         // Convert last four digits of page ID
         return _wtoi(pageid.substr(2).c_str());
      }
Пример #5
0
inline void getAttributesFromHTMLDOMNode(IHTMLDOMNode* pHTMLDOMNode,wstring& nodeName, map<wstring,wstring>& attribsMap) {
	int res=0;
	IDispatch* pDispatch=NULL;
	LOG_DEBUG(L"Getting IHTMLDOMNode::attributes");
	if(pHTMLDOMNode->get_attributes(&pDispatch)!=S_OK||!pDispatch) {
		LOG_DEBUG(L"pHTMLDOMNode->get_attributes failed");
		return;
	}
	IHTMLAttributeCollection2* pHTMLAttributeCollection2=NULL;
	res=pDispatch->QueryInterface(IID_IHTMLAttributeCollection2,(void**)&pHTMLAttributeCollection2);
	pDispatch->Release();
	if(res!=S_OK) {
		LOG_DEBUG(L"Could not get IHTMLAttributesCollection2");
		return;
	}
	IHTMLDOMAttribute* tempAttribNode=NULL;
	VARIANT tempVar;
	macro_addHTMLAttributeToMap(L"id",false,pHTMLAttributeCollection2,attribsMap,tempVar,tempAttribNode);
	if(nodeName.compare(L"TABLE")==0) {
		macro_addHTMLAttributeToMap(L"summary",false,pHTMLAttributeCollection2,attribsMap,tempVar,tempAttribNode);
	} else if(nodeName.compare(L"A")==0) {
		macro_addHTMLAttributeToMap(L"href",true,pHTMLAttributeCollection2,attribsMap,tempVar,tempAttribNode);
	} else if(nodeName.compare(L"INPUT")==0) {
		macro_addHTMLAttributeToMap(L"type",false,pHTMLAttributeCollection2,attribsMap,tempVar,tempAttribNode);
		macro_addHTMLAttributeToMap(L"value",false,pHTMLAttributeCollection2,attribsMap,tempVar,tempAttribNode);
	} else if(nodeName.compare(L"TD")==0||nodeName.compare(L"TH")==0) {
		macro_addHTMLAttributeToMap(L"headers",false,pHTMLAttributeCollection2,attribsMap,tempVar,tempAttribNode);
		macro_addHTMLAttributeToMap(L"colspan",false,pHTMLAttributeCollection2,attribsMap,tempVar,tempAttribNode);
		macro_addHTMLAttributeToMap(L"rowspan",false,pHTMLAttributeCollection2,attribsMap,tempVar,tempAttribNode);
		macro_addHTMLAttributeToMap(L"scope",false,pHTMLAttributeCollection2,attribsMap,tempVar,tempAttribNode);
	}
	macro_addHTMLAttributeToMap(L"longdesc",false,pHTMLAttributeCollection2,attribsMap,tempVar,tempAttribNode);
	macro_addHTMLAttributeToMap(L"alt",true,pHTMLAttributeCollection2,attribsMap,tempVar,tempAttribNode);
	macro_addHTMLAttributeToMap(L"title",false,pHTMLAttributeCollection2,attribsMap,tempVar,tempAttribNode);
	macro_addHTMLAttributeToMap(L"src",false,pHTMLAttributeCollection2,attribsMap,tempVar,tempAttribNode);
	macro_addHTMLAttributeToMap(L"onclick",false,pHTMLAttributeCollection2,attribsMap,tempVar,tempAttribNode);
	macro_addHTMLAttributeToMap(L"onmousedown",false,pHTMLAttributeCollection2,attribsMap,tempVar,tempAttribNode);
	macro_addHTMLAttributeToMap(L"onmouseup",false,pHTMLAttributeCollection2,attribsMap,tempVar,tempAttribNode);
	//ARIA properties:
	macro_addHTMLAttributeToMap(L"role",false,pHTMLAttributeCollection2,attribsMap,tempVar,tempAttribNode);
	macro_addHTMLAttributeToMap(L"aria-valuenow",false,pHTMLAttributeCollection2,attribsMap,tempVar,tempAttribNode);
	macro_addHTMLAttributeToMap(L"aria-sort",false,pHTMLAttributeCollection2,attribsMap,tempVar,tempAttribNode);
	macro_addHTMLAttributeToMap(L"aria-labelledBy",false,pHTMLAttributeCollection2,attribsMap,tempVar,tempAttribNode);
	macro_addHTMLAttributeToMap(L"aria-describedBy",false,pHTMLAttributeCollection2,attribsMap,tempVar,tempAttribNode);
	macro_addHTMLAttributeToMap(L"aria-expanded",false,pHTMLAttributeCollection2,attribsMap,tempVar,tempAttribNode);
	macro_addHTMLAttributeToMap(L"aria-selected",false,pHTMLAttributeCollection2,attribsMap,tempVar,tempAttribNode);
	macro_addHTMLAttributeToMap(L"aria-level",false,pHTMLAttributeCollection2,attribsMap,tempVar,tempAttribNode);
	macro_addHTMLAttributeToMap(L"aria-required",false,pHTMLAttributeCollection2,attribsMap,tempVar,tempAttribNode);
	macro_addHTMLAttributeToMap(L"aria-dropeffect",false,pHTMLAttributeCollection2,attribsMap,tempVar,tempAttribNode);
	macro_addHTMLAttributeToMap(L"aria-grabbed",false,pHTMLAttributeCollection2,attribsMap,tempVar,tempAttribNode);
	macro_addHTMLAttributeToMap(L"aria-invalid",false,pHTMLAttributeCollection2,attribsMap,tempVar,tempAttribNode);
	macro_addHTMLAttributeToMap(L"aria-multiline",false,pHTMLAttributeCollection2,attribsMap,tempVar,tempAttribNode);
	macro_addHTMLAttributeToMap(L"aria-label",false,pHTMLAttributeCollection2,attribsMap,tempVar,tempAttribNode);
	macro_addHTMLAttributeToMap(L"aria-hidden",false,pHTMLAttributeCollection2,attribsMap,tempVar,tempAttribNode);
	pHTMLAttributeCollection2->Release();
}
Пример #6
0
bkplong bkpStr2Int(const wstring &src)
{
	if(!src.compare(L"true"))return 1;
	if(!src.compare(L"false"))return 0;
	if(!src.compare(L"void"))return 0;
	if (src[0] == '-')
		return -(bkplong)bkpwcstoxl(&src[1], NULL, 0);
	if (src[0] == L'#')
		return bkpColor2Int(src);
	return bkpwcstoxl(src.c_str(), NULL, 0);
}
bool IEAcceptLanguagesAction::_isCurrentLanguageOk(wstring& firstlang)
{
	wstring langcode;

	_readLanguageCode(langcode);
	_parseLanguage(langcode);
	_getFirstLanguage(firstlang);

	// IE 6.0 uses two digit language codes, after IE 6 can also include country
	return firstlang.compare(L"ca-es") == 0 || firstlang.compare(L"ca") == 0;
}
Пример #8
0
double str2num(const wstring &src)
{
	if(!src.compare(L"true"))return 1;
	if(!src.compare(L"false"))return 0;
	if(!src.compare(L"void"))return 0;
	if (src[0] == '-')
		return -bkpwcstonum(&src[1], NULL);
	if (src[0] == L'#')
		return bkpColor2Int(src);
	return bkpwcstonum(src.c_str(), NULL);
}
Пример #9
0
INT cInjector::InjectToProcess(wstring wProcName, wstring wDllName)
{
	HANDLE hSnapshot;
	PROCESSENTRY32 ProcessEntry;
	INT nCount = 0;

	hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);

	if(hSnapshot != INVALID_HANDLE_VALUE)
	{
		ProcessEntry.dwSize = sizeof(PROCESSENTRY32);

		if(Process32First(hSnapshot, &ProcessEntry))
			do {
				if(!wProcName.compare(ProcessEntry.szExeFile))
				{
					HMODULE hDll = cInjector::GetRemoteDll(ProcessEntry.th32ProcessID, wDllName);

					if(!hDll)
						cInjector::InjectDLL(ProcessEntry.th32ProcessID, wDllName);
					else cInjector::UnloadDLL(ProcessEntry.th32ProcessID, hDll);

					nCount++;
				}

				ProcessEntry.dwSize = sizeof(PROCESSENTRY32);
			} while(Process32Next(hSnapshot, &ProcessEntry));
	}

	CloseHandle(hSnapshot);

	return nCount;
}
Пример #10
0
// Function to check the endig of a string
bool HasEnding(wstring const &fullString, wstring const &ending)
{
	if (fullString.length() >= ending.length())
		return (0 == fullString.compare(fullString.length() - ending.length(), ending.length(), ending));
	else
		return false;
}
Пример #11
0
VRegisteredDatabase::VRegisteredDatabase(const wstring& in_fullstring)
{
	if (in_fullstring.compare(L"")!=0)
	{
		std::vector<wstring> split_vec;
		boost::algorithm::split(split_vec, in_fullstring, boost::is_any_of(L";"));
		if (split_vec.size()==4)
		{
			name = split_vec.at(0);
			server = split_vec.at(1);			
			database = split_vec.at(2);
			folder = split_vec.at(3);
			count_days_backup = 7;
		}
		else if(split_vec.size()>=5)
		{
			//есть информаци¤ о кол-ве дней, допустимых без резервного копировани¤
			name = split_vec.at(0);
			server = split_vec.at(1);
			database = split_vec.at(2);
			folder = split_vec.at(3);
			count_days_backup = atoi(wstring_to_string(split_vec.at(4).c_str()).c_str());
		}
		else
		{
			throw VSimpleException(L"ќшибка разбора строки", in_fullstring, boost::str(boost::wformat(L"%s") % __FILE__), __LINE__);
		}
	}
};
Пример #12
0
int WindDataParser::GetStrItemIndexOfSafeArray(const VARIANT& safeArray, const wstring& itemNameStr)
{
	if(!IsArray(safeArray))
	{
		return -1;
	}

	int length = GetCountOfSafeArray(safeArray);

	HRESULT hr ;
	BSTR *pbItems;

	hr = SafeArrayAccessData(safeArray.parray, (void HUGEP**)&pbItems);
	if (FAILED(hr))
	{
		return -1;
	}
	int nRetIndex = -1;
	for(int index = 0; index < length; index++)
	{
		if (0 == itemNameStr.compare(pbItems[index]))
		{
			nRetIndex = index;
			break;
		}
	}
	SafeArrayUnaccessData(safeArray.parray);

	return nRetIndex;
}
Пример #13
0
void PSBoolReader::Read(const wstring& inReadFrom,bool& outValue)
{
	if(inReadFrom.compare(L"true") == 0)
		outValue = true;
	else
		outValue = false;
}
Пример #14
0
bool ConfigWrapper::GetwstringValueFromConfig( const wstring& strKey, wstring& strValue )
{
	if ( NUMBER_ZERO == strKey.compare( NULL_STRING ))
	{
		return false;
	}

	if ( NULL == m_pConfigManager )
	{
		return false;
	}

	ConfigValue* pSingleNode = NULL;
//	pSingleNode = m_pConfigManager->SelectSingleNode( strKey );

	TCHAR szNodeValue[MAX_VALUE_LENGTH];

	DWORD dwReturnSize = pSingleNode->GetValue( szNodeValue );
	strValue = szNodeValue;

	if ( NULL != pSingleNode )
	{
		delete pSingleNode;
		pSingleNode = NULL;
	}

	return true;
}
Пример #15
0
bool isImageFile(wstring &filename)
{
        for (int i=0; imgtypelist[i] != NULL; i++)
	{
            if (filename.compare(imgtypelist[i]) == 0)
                return true;
	}
	return false;
}
Пример #16
0
bool NBTools::EndsWith(wstring check, wstring end)
{
    if (check.length() >= end.length()) {
        return (0 == check.compare(check.length() - end.length(), end.length(), end));
    } else {
        return false;
    }

}
Пример #17
0
double CAndorSDK3Camera::CalculateDefaultExposure(wstring & interfaceType)
{
   double d_retValue = 0.0340f;
   if (0 == interfaceType.compare(L"CL 10 Tap") )
   {
      d_retValue = 0.0100f;
   }
   return d_retValue;
}
Пример #18
0
inline wstring
_prefix_port_if_needed(const wstring &input)
{
  static wstring windows_com_port_prefix = L"\\\\.\\";
  if (input.compare(windows_com_port_prefix) != 0)
  {
    return windows_com_port_prefix + input;
  }
  return input;
}
Пример #19
0
    /**
        Compare strings case insensitive

        \param       str1   First string to compare
        \param       str2   Second string to compare
        \param       ci     Boolean whether comparision should be case-insensitive or not

        \returns     0 if equal, <0 if first string is less, >0 if first string is greater

    */
    int StrCompare(const wstring& str1, const wstring& str2, bool ci)
    {
        if (ci)
        {
            return StrToUpper(str1).compare(StrToUpper(str2));
        }
        else
        {
            return str1.compare(str2);
        }
    }
Пример #20
0
int ConfigWrapper::SetConfigParameters( const wstring& strPatchName )
{
	if ( NUMBER_ZERO == strPatchName.compare( NULL_STRING ))
	{
		return ERROR_XMLFILE_INVALID;
	}

	m_strPatchName = strPatchName;

	return RETURN_SUCCESS;		
}
Пример #21
0
bool strIsPrefixed(const wstring& str,const wstring& prefix)
{
	if(prefix.empty())
	{
		return true;
	}
	if(prefix.length()>str.length())
	{
		return false;
	}
	return str.compare(0,prefix.length(),prefix)==0;
}
Пример #22
0
bool AccountInfo::IsSpecialType( wstring str )
{
	vector<wstring>::iterator it = vSpecialType.begin();
	while( it != vSpecialType.end() )
	{
		if ( str.compare(*it) == 0 )
		{
			return true;
		}
		it++;
	}
	return false;
}
Пример #23
0
CAndorSDK3Camera::CameraId CAndorSDK3Camera::DetermineCameraId(wstring & cameraSerialCheck)
{
   CameraId id = CIDNeo;
   try {
      cameraSerialCheck.erase(4);
      if (0 == cameraSerialCheck.compare(L"VSC-") )
      {
         id = CIDZyla;
      }
   }
   catch (const std::out_of_range&)
   {
   }
   return id;
}
Пример #24
0
/*
	getIndexOfWString - This method searches for the key
	parameter in the wstring table. If found, it returns it's index, if
	not found it returns the max unsigned int value;
*/
unsigned int WStringTable::getIndexOfWString(wstring key)
{
	unsigned int counter = 0;
	vector<wstring>::iterator it = wStringTable.begin();
	while(it != wStringTable.end())
	{
		if (key.compare((*it)) == 0)
			return counter;
		it++;
		counter++;
	}
	unsigned int max = 0;
	max -= 1;
	return max;
}
Пример #25
0
int stringCompare( const wstring& s1, const wstring& s2, bool caseSensitive )
{
    if( !caseSensitive )
    {
        wstring text1( s1 );
        wstring text2( s2 );

        toUpper( text1 );
        toUpper(text2);

        return text1.compare( text2 );
    }
    else
    {
        return s1.compare( s2 );
    }
}
Пример #26
0
std::string CAndorSDK3Camera::GenerateCameraName(unsigned cameraID, wstring & cameraModelCheck)
{
   string s_cameraName("Neo 5.5 "); 
   if (CIDZyla == cameraID)
   {
      try {
         cameraModelCheck.erase(8);
      }
      catch (const std::out_of_range&)
      {
         cameraModelCheck.erase();
      }

      s_cameraName = "Zyla 5.5 ";
      if (0 == cameraModelCheck.compare(L"ZYLA-4.2") )
      {
         s_cameraName = "Zyla 4.2 ";
      }
   }
   return s_cameraName;
}
Пример #27
0
/*
* Accepts a list of lines from a release file, and finds values.
* Lines should look like:
* OSName=Red Hat text...
* OSVersion=0.0
* etc.
* In the first case, if this function is passed "OSName" in the sToken param, then sValue
* will be populated with everything after the '=' to EOL or EOF as the case may be.
*/
bool SCXOSTypeInfo::ExtractToken(const wstring& sToken, const vector<wstring>& list, wstring& sValue)
{
    vector<wstring> tok_list;
    for(vector<wstring>::const_iterator li = list.begin(); li != list.end(); ++li)
    {
        // returns vector like {"OSName", "Redhat text"}, pretrimmed
        StrTokenize((*li), tok_list, L"=");
        if (tok_list.size()== 2)
        {
            //if this line does not start with token, skip it
            if (0 != sToken.compare(tok_list[0]))
            {
                continue;
            }

            sValue = tok_list[1];
            return true;
        }
    }

    return false;
}
Пример #28
0
HMODULE cInjector::GetRemoteDll(DWORD dwPid, wstring wDllName)
{
	MODULEENTRY32W ModEntry;

	HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, dwPid);

	ModEntry.dwSize = sizeof(MODULEENTRY32W);

	if(Module32First(hSnapshot, &ModEntry))
		do {
			if(!wDllName.compare(ModEntry.szModule))
			{
				CloseHandle(hSnapshot);
				return ModEntry.hModule;
			}

			ModEntry.dwSize = sizeof(MODULEENTRY32);
		} while(Module32Next(hSnapshot, &ModEntry));

	CloseHandle(hSnapshot);

	return NULL;
}
void BalloonEscapeButtonEventHandler::handleButtonEvents(	Game *game, 
													wstring command)
{
	// THE USER PRESSED THE Exit BUTTON ON THE MAIN MENU,
	// SO LET'S SHUTDOWN THE ENTIRE APPLICATION
	if (command.compare(W_EXIT_COMMAND) == 0)
	{
		game->shutdown();
	}
	// THE USER PRESSED THE MOUSE BUTTON ON THE SPLASH
	// SCREEN, SO LET'S GO TO THE MAIN MENU
	else if (command.compare(W_GO_TO_MM_COMMAND) == 0)
	{
		GameStateManager *gsm = game->getGSM();
		gsm->goToMainMenu();
		PlaySound(L"data/sounds/start.wav", NULL, SND_FILENAME|SND_ASYNC);
	}
	// THE USER PRESSED THE Start BUTTON ON THE MAIN MENU,
	// SO LET'S START THE GAME FROM THE FIRST LEVEL
	else if (command.compare(W_START_COMMAND) == 0)
	{
		game->setCurrentLevel(W_LEVEL_1_NAME,W_LEVEL_1_DIR);
		game->startGame();
		PlaySound(L"data/sounds/theme.wav", NULL, SND_FILENAME|SND_ASYNC);
	}
	// THE USER PRESSED THE Quit BUTTON ON THE IN-GAME MENU,
	// SO LET'S UNLOAD THE LEVEL AND RETURN TO THE MAIN MENU
	else if (command.compare(W_QUIT_COMMAND) == 0)
	{
		game->quitGame();
		PlaySound(L"data/sounds/jump.wav", NULL, SND_FILENAME|SND_ASYNC);
	}
	else if (command.compare(W_HELP_COMMAND) == 0)
	{
		GameStateManager *gsm = game->getGSM();
		gsm->Help();
		PlaySound(L"data/sounds/jump.wav", NULL, SND_FILENAME|SND_ASYNC);
	}
	else if (command.compare(W_ABOUT_COMMAND) == 0)
	{
		GameStateManager *gsm = game->getGSM();
		gsm->About();
		PlaySound(L"data/sounds/jump.wav", NULL, SND_FILENAME|SND_ASYNC);
	}
}
Пример #30
0
bool EndsWith(const wstring& str1, const wstring& str2) {
  if (str2.length() > str1.length())
    return false;

  return str1.compare(str1.length() - str2.length(), str2.length(), str2) == 0;
}