コード例 #1
0
ファイル: Environment.cpp プロジェクト: Eli2/ArxLibertatis
std::string ws2s(const std::basic_string<WCHAR> & s) {
	size_t slength = (int)s.length() + 1;
	size_t len = WideCharToMultiByte(CP_ACP, 0, s.c_str(), slength, 0, 0, 0, 0); 
	std::string r(len, '\0');
	WideCharToMultiByte(CP_ACP, 0, s.c_str(), slength, &r[0], len, 0, 0); 
	return r;
}
コード例 #2
0
long CMetronomeDlg_RegPersist::OnExportPresetButton(unsigned long const nIgnore1, long const nIgnore2) 
{
    OPENFILENAME ofn;
    TCHAR szE[] = _T("/e \"");
    TCHAR szR[] = _T("\" \"HKEY_CURRENT_USER\\Software\\BHBSoftware\\Open Metronome\"");
    TCHAR szWholeFile[MAX_PATH + sizeof(szE) + sizeof(szR)] = _T("");       // buffer for file name
    TCHAR szFile[255];       // buffer for file name
    TCHAR title[255];        //buffer for file title

    ZeroMemory(&ofn, sizeof(ofn));
    ofn.lStructSize = sizeof(ofn);
    ofn.hwndOwner = m_hWnd;
    ofn.lpstrFile = szFile;
    ofn.lpstrFileTitle = title;
    
    //
    // Set lpstrFile[0] to '\0' so that GetOpenFileName does not 
    // use the contents of szFile to initialize itself.
    ofn.lpstrFile[0] = (TCHAR)'\0';
    ofn.lpstrDefExt = _T("REG");
    ofn.lpstrFileTitle[0] = (TCHAR)'\0';
    ofn.nMaxFile = sizeof(szFile);
    ofn.nMaxFileTitle = sizeof(title);

#ifdef USE_WEIRD_MIDI
    ofn.lpstrFilter = _T("Registry Files (*.REG)\0*.REG\0\0");
#else //USE_WEIRD_WAV
    ofn.lpstrFilter = _T("Wave Sound (*.WAV)\0*.WAV\0Registry Files (*.REG)\0*.REG\0\0");
#endif

    ofn.nFilterIndex = 1;
    
    ofn.Flags = OFN_OVERWRITEPROMPT;

    if(GetSaveFileName(&ofn) == IDOK) 
    {
        std::basic_string<TCHAR> const strFilename(ofn.lpstrFile);
        if (_tcsstr(_tcsupr(ofn.lpstrFile), _T(".WAV"))-ofn.lpstrFile == strFilename.length()-4)
        {
            if (BuildPlayerInstance())
            {
                if (m_autopTicker.get())
                {
                    m_autopTicker->Export(strFilename.c_str(), m_NumExp);
                    m_autopTicker = (std::auto_ptr<IBeatBox>) NULL;
                }
            }
        }
#ifndef UNDER_CE
        else
        {
            _tcscpy(szWholeFile, szE);
            _tcscat(szWholeFile, strFilename.c_str());
            _tcscat(szWholeFile, szR);
	        ShellExecute(this->m_hWnd, _T("open"), _T("regedit"), szWholeFile, 0, SW_SHOWNORMAL);
        }
#endif
    }
    return 0;
}
コード例 #3
0
ファイル: winapi.hpp プロジェクト: thenfour/LibCC
		void FromFile(const std::basic_string<WCHAR>& pathW)
		{
			DWORD wtf;
			DWORD size;

			Translations.clear();

			size = GetFileVersionInfoSizeW(pathW.c_str(), &wtf);
			if(!size)
				return;

      data.resize(size);
			if(!GetFileVersionInfoW(pathW.c_str(), 0, size, data.data()))
				return;

			// fixed info (main shit)
			VS_FIXEDFILEINFO* ffi = 0;
			UINT ffilen = 0;
			if(!VerQueryValueW(data.data(), L"\\", (void**)&ffi, &ffilen))
				return;
			m_a = HIWORD(ffi->dwFileVersionMS);
			m_b = LOWORD(ffi->dwFileVersionMS);
			m_c = HIWORD(ffi->dwProductVersionLS);
			m_d = LOWORD(ffi->dwProductVersionLS);

			// Read the list of languages and code pages.
			LANGANDCODEPAGE* lpTranslate;
			VerQueryValueW(data.data(), L"\\VarFileInfo\\Translation", (LPVOID*)&lpTranslate, &ffilen);

			for(unsigned i = 0; i < (ffilen / sizeof(LANGANDCODEPAGE)); i++)
			{
				Translations.push_back(lpTranslate[i]);
			}
		}
コード例 #4
0
    std::basic_string< char > str_convert< char, wchar_t >( std::basic_string< wchar_t > const & src )
    {
        std::basic_string< char > dst;

        if ( !src.empty() )
        {
            std::unique_lock< std::mutex > lock( g_conversionMutex );
            char * szloc = setlocale( LC_CTYPE, "" );
            size_t size = wcstombs( NULL, src.c_str(), 0 ) + 1;
            char * buffer = NULL;
            {
                auto guard = make_block_guard( [&buffer, &size]()
                {
                    buffer = new char[size + 1];
                }, [&buffer]()
                {
                    delete [] buffer;
                } );

                size = std::min( size, wcstombs( buffer, src.c_str(), size ) );
                setlocale( LC_CTYPE, szloc );
                dst.assign( buffer, buffer + size );
            }
        }

        return dst;
    }
コード例 #5
0
ファイル: message_box.hpp プロジェクト: alamaison/washer
    inline button_type::type message_box(
        HWND hwnd, const std::basic_string<T>& message,
        const std::basic_string<T>& title, box_type::type box,
        icon_type::type icon, unsigned int default_button, bool show_help)
    {
        unsigned int type = 0;
        type |= detail::box_type_to_mb_box(box);
        type |= detail::icon_type_to_mb_icon(icon);

        unsigned int max_default_button = button_count_from_box_type(box);
        if (show_help)
        {
            type |= MB_HELP;
            max_default_button++;
        }

        if (default_button > max_default_button)
            BOOST_THROW_EXCEPTION(
                std::invalid_argument("Default button out-of-range"));
        type |= default_to_mb_default(default_button);

        int rc = native::message_box(
            hwnd, message.c_str(), title.c_str(), type);
        if (rc == 0)
            BOOST_THROW_EXCEPTION(
                boost::enable_error_info(washer::last_error()) <<
                boost::errinfo_api_function("MessageBox"));

        return detail::mb_button_to_button_type(rc);
    }
コード例 #6
0
ファイル: XMLParserTest.cpp プロジェクト: rayfill/cpplib
	void TokenizerTest()
	{
		const std::basic_string<utf16_t> xmlText =
			Transcoder::UTF8toUTF16("<token1><token2 />\nhello world.\nhello xml.</token1>");
		XMLParser<utf16_t>::Tokenizer tokenizer(xmlText.c_str(), xmlText.c_str() + xmlText.size());

		std::basic_string<utf16_t> result = tokenizer.getToken();
		CPPUNIT_ASSERT_MESSAGE(Transcoder::UTF16toUTF8(result),
							   result == Transcoder::UTF8toUTF16("<token1>"));

		result = tokenizer.getToken();
		CPPUNIT_ASSERT_MESSAGE(Transcoder::UTF16toUTF8(result),
							   result == Transcoder::UTF8toUTF16("<token2 />"));

		result = tokenizer.getToken();
		CPPUNIT_ASSERT_MESSAGE(Transcoder::UTF16toUTF8(result),
							   result == Transcoder::UTF8toUTF16("\nhello world.\nhello xml."));

		result = tokenizer.getToken();
		CPPUNIT_ASSERT_MESSAGE(Transcoder::UTF16toUTF8(result),
							   result == Transcoder::UTF8toUTF16("</token1>"));

		CPPUNIT_ASSERT(tokenizer.isEof());

		result = tokenizer.getToken();
		CPPUNIT_ASSERT_MESSAGE(Transcoder::UTF16toUTF8(result),
							   result == Transcoder::UTF8toUTF16(""));

		CPPUNIT_ASSERT(tokenizer.isEof());
	}
コード例 #7
0
void test_normc(std::basic_string<Char> orig,std::basic_string<Char> normal,boost::locale::norm_type type)
{
    std::locale l = boost::locale::generator().generate("en_US.UTF-8");
    TEST(boost::locale::normalize(orig,type,l)==normal);
    TEST(boost::locale::normalize(orig.c_str(),type,l)==normal);
    TEST(boost::locale::normalize(orig.c_str(),orig.c_str()+orig.size(),type,l)==normal);
}
コード例 #8
0
// if TCHAR is defined as WCHAR, we have to do unicode conversion
void mv(std::string& lhs, const std::basic_string<WCHAR>& rhs) {
  auto size_needed = WideCharToMultiByte(CP_UTF8, 0, rhs.c_str(),
                                         static_cast<int>(rhs.size()),
                                         nullptr, 0, nullptr, nullptr);
  lhs.resize(size_needed);
  WideCharToMultiByte(CP_UTF8, 0, rhs.c_str(), static_cast<int>(rhs.size()),
                      &lhs[0], size_needed, nullptr, nullptr);
}
コード例 #9
0
/* ------------------------------------------------------------------------- */
void associate(const std::basic_string<TCHAR>& key, const std::basic_string<TCHAR>& value, bool flag) {
	static const TCHAR* clsid_associate = _T("{F3DB85F4-4731-4e80-BC2E-754A7320D830}");
	static const TCHAR* clsid_tooltip = _T("{00021500-0000-0000-C000-000000000046}");
	HKEY subkey;
	LONG status = RegOpenKeyEx(HKEY_CLASSES_ROOT, ( key + _T( "\\shellex" ) ).c_str(), 0, KEY_ALL_ACCESS, &subkey );
	
	if( !status ) {
		RegDeleteKeyNT( subkey, clsid_tooltip );
		RegCloseKey( subkey );
	}
	
	if (flag) {
		DWORD disposition = 0;
		LONG status = RegCreateKeyEx(HKEY_CLASSES_ROOT, key.c_str(), 0, _T(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &subkey, &disposition);
		if (!status) { 
			TCHAR buffer[32] = {};
			DWORD type = 0;
			DWORD size = sizeof(buffer);
			if (RegQueryValueEx(subkey, _T(""), NULL, &type, (LPBYTE)buffer, &size) == ERROR_SUCCESS && std::basic_string<TCHAR>(buffer) != value) {
				RegSetValueEx(subkey, CUBEICE_REG_PREVARCHIVER, 0, REG_SZ, (CONST BYTE*)buffer, (_tcslen(buffer) + 1) * sizeof(TCHAR));
			}
			RegSetValueEx(subkey, _T(""), 0, REG_SZ, (CONST BYTE*)value.c_str(), (value.size() + 1) * sizeof(TCHAR));
			
			disposition = 0;
			status = RegCreateKeyEx(HKEY_CLASSES_ROOT, ( key + _T( "\\shellex\\") + clsid_tooltip ).c_str(), 0, _T(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &subkey, &disposition);
			if (!status) {
				RegSetValueEx(subkey, _T(""), 0, REG_SZ, (CONST BYTE*)clsid_associate, (_tcslen(clsid_associate) + 1) * sizeof(TCHAR));
			}
		}
	}
	else {
		LONG status = RegOpenKeyEx(HKEY_CLASSES_ROOT, key.c_str(), 0, KEY_ALL_ACCESS, &subkey);
		if (!status) {
			TCHAR buffer[32] = {};
			DWORD type = 0;
			DWORD size = sizeof(buffer);
			if (RegQueryValueEx(subkey, _T(""), NULL, &type, (LPBYTE)buffer, &size) == ERROR_SUCCESS && std::basic_string<TCHAR>(buffer) == value) {
				TCHAR prev[32] = {};
				type = 0;
				size = sizeof(prev);
				if (RegQueryValueEx(subkey, CUBEICE_REG_PREVARCHIVER, NULL, &type, (LPBYTE)prev, &size) == ERROR_SUCCESS) {
					RegSetValueEx(subkey, _T(""), 0, REG_SZ, (CONST BYTE*)prev, (_tcslen(prev) + 1) * sizeof(TCHAR));
				}
				else {
					RegCloseKey(subkey);
					RegDeleteKeyNT(HKEY_CLASSES_ROOT, key.c_str());
				}
			}
		}
	}
}
コード例 #10
0
Error ShellExecute(const std::basic_string<charT, traits, Allocator>& fileName   = std::basic_string<charT, traits, Allocator>(),
                   const std::basic_string<charT, traits, Allocator>& operation  = std::basic_string<charT, traits, Allocator>(),
                   const std::basic_string<charT, traits, Allocator>& parameters = std::basic_string<charT, traits, Allocator>(),
                   const std::basic_string<charT, traits, Allocator>& directory  = std::basic_string<charT, traits, Allocator>(),
                   HWND hwnd = HWND(NULL),
                   show_command showCmd = show_command_normal)
{
    const charT * const file = fileName.c_str();
    const charT * const op     = operation.empty()  ? NULL : operation.c_str();
    const charT * const params = parameters.empty() ? NULL : parameters.c_str();
    const charT * const dir    = directory.empty()  ? NULL : directory.c_str();

    return ShellExecute(hwnd, op, file, params, dir, showCmd);
}
コード例 #11
0
ファイル: filesystem.hpp プロジェクト: steve6390/nana
	std::basic_string<CharType> parent_path(const std::basic_string<CharType>& path)
	{	
		auto index = path.size();

		if (index)
		{
			auto str = path.c_str();

			for (--index; index > 0; --index)
			{
				auto c = str[index];
				if (c != '\\' && c != '/')
					break;
			}

			for (--index; index > 0; --index)
			{
				auto c = str[index];
				if (c == '\\' || c == '/')
					break;
			}
		}

		return index ? path.substr(0, index + 1) : std::basic_string<CharType>();
	}
コード例 #12
0
    void read_config
    (
        const std::basic_string<Ch>& a_filename,
        basic_variant_tree<Ch>&      a_tree,
        const boost::function<bool (std::basic_string<Ch>& a_filename)>
                                     a_resolver = inc_file_resolver<Ch>(),
        int                          a_flags = 0,
        const std::locale &          a_loc   = std::locale(),
        config_format                a_fmt   = FORMAT_UNDEFINED
    ) {
        std::basic_string<Ch> ext = boost::filesystem::extension(a_filename);

        if (a_fmt == FORMAT_UNDEFINED) {
            if (ext == ".config" || ext == ".conf" || ext == ".cfg" || ext == ".scon")
                a_fmt = FORMAT_SCON;
            else if (ext == ".ini")
                a_fmt = FORMAT_INI;
            else if (ext == ".xml")
                a_fmt = FORMAT_XML;
            else
                throw std::runtime_error("Configuration file extension not supported!");
        }

        std::basic_ifstream<Ch> stream(a_filename.c_str());
        if (!stream)
            throw variant_tree_parser_error(
                "cannot open file for reading", a_filename, 0);
        stream.imbue(a_loc);
        read_config(stream, a_tree, a_fmt, a_filename, a_resolver, a_flags);
    }
コード例 #13
0
ファイル: string_generate.hpp プロジェクト: gitrider/wxsj2
 inline bool string_generate(OutputIterator& sink
   , std::basic_string<Char, Traits, Allocator> const& str
   , CharEncoding, Tag)
 {
     return string_generate(sink, str.c_str()
       , encoding_filter<CharEncoding, Tag>());
 }
コード例 #14
0
ファイル: ErrorHandling.cpp プロジェクト: FreedomBen/aescrypt
/*
 * ReportError
 *
 * Report an error to the user
 */
void ReportError(   std::basic_string<TCHAR> message,
                    DWORD reason)
{
    LPTSTR error_string;

    if (reason != ERROR_SUCCESS)
    {
        if (::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
                    FORMAT_MESSAGE_FROM_SYSTEM,
                    NULL,
                    reason,
                    0,
                    (LPTSTR)&error_string,
                    0,
                    NULL) != 0)
        {
            LPTSTR p = _tcschr(error_string, _T('\r'));
            if(p != NULL)
            {
                *p = _T('\0');
            }

            message += _T(":\n");
            message += error_string;

            ::LocalFree(error_string);
        }
    }

    ::MessageBox(NULL,message.c_str(),_T("AES Crypt Error"), MB_OK);
}
コード例 #15
0
ファイル: zip.hpp プロジェクト: chenyu2202863/smart_cpp_lib
	inline bool unzip(const BufferT &inBuf, const std::basic_string<TCHAR> &path)		
	{
		auto_zip hz = ::OpenZip(inBuf.first.get(), inBuf.second, ZIP_MEMORY, path.c_str());
		if( !hz.IsValid() )
			return false;

		ZIPENTRYW ze = {0}; 
		HRESULT hRes = ::GetZipItem(hz, -1 ,&ze); 
		if( hRes != S_OK )
			return false;

		int numitems = ze.index;
		for(int i=0; i != numitems; ++i)
		{ 
			hRes = ::GetZipItem(hz,i, &ze);
			if( hRes != S_OK )
				return false;

			hRes = ::UnzipItem(hz, i, ze.name, 0, ZIP_FILENAME);
			if( hRes != S_OK )
				return false;
		}

		return true;
	}
コード例 #16
0
 inline proto::terminal<in_state_tag<char const*> >::type
 in_state(std::basic_string<Char, Traits, Allocator> const& s)
 {
     typename proto::terminal<in_state_tag<Char const*> >::type that = 
         {{s.c_str()}};
     return that;
 }
コード例 #17
0
ファイル: MadEditSearch.cpp プロジェクト: elleryq/madedit
 void Build(const wxByte* pat, size_t len)
 {
     if(m_Pattern.length()==len && IsTheSame(m_Pattern.c_str(), pat, (int)len)) return;
     m_Pattern.assign(pat, len);
     for(size_t i=0; i<256; ++i) m_Table[i] = (int)len+1;
     for(size_t i=0; i<len; ++i) m_Table[pat[i]] = (int)(len-i);
 }
コード例 #18
0
ファイル: IOWin.cpp プロジェクト: spankminister/dolphin
static bool IsWiimote(const std::basic_string<TCHAR>& device_path, WinWriteMethod& method)
{
  HANDLE dev_handle = CreateFile(device_path.c_str(), GENERIC_READ | GENERIC_WRITE,
                                 FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING,
                                 FILE_FLAG_OVERLAPPED, nullptr);
  if (dev_handle == INVALID_HANDLE_VALUE)
    return false;

  u8 buf[MAX_PAYLOAD];
  u8 const req_status_report[] = {WM_SET_REPORT | WM_BT_OUTPUT, WM_REQUEST_STATUS, 0};
  int invalid_report_count = 0;
  int rc = WriteToHandle(dev_handle, method, req_status_report, sizeof(req_status_report));
  while (rc > 0)
  {
    rc = ReadFromHandle(dev_handle, buf);
    if (rc <= 0)
      break;

    switch (buf[1])
    {
    case WM_STATUS_REPORT:
      return true;
    default:
      WARN_LOG(WIIMOTE, "IsWiimote(): Received unexpected report %02x", buf[1]);
      invalid_report_count++;
      // If we receive over 15 invalid reports, then this is probably not a Wiimote.
      if (invalid_report_count > 15)
        return false;
    }
  }
  return false;
}
コード例 #19
0
ファイル: Process.cpp プロジェクト: ApocalypsEnd/Blackbone
/// <summary>
/// Grant current process arbitrary privilege
/// </summary>
/// <param name="name">Privilege name</param>
/// <returns>Status</returns>
NTSTATUS Process::GrantPriviledge( const std::basic_string<TCHAR>& name )
{
    TOKEN_PRIVILEGES Priv, PrivOld;
    DWORD cbPriv = sizeof(PrivOld);
    HANDLE hToken;

    if (!OpenThreadToken( GetCurrentThread(), TOKEN_QUERY | TOKEN_ADJUST_PRIVILEGES, FALSE, &hToken ))
    {
        if (GetLastError() != ERROR_NO_TOKEN)
            return LastNtStatus();

        if (!OpenProcessToken( GetCurrentProcess(), TOKEN_QUERY | TOKEN_ADJUST_PRIVILEGES, &hToken ))
            return LastNtStatus();
    }

    Priv.PrivilegeCount = 1;
    Priv.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
    LookupPrivilegeValue( NULL, name.c_str(), &Priv.Privileges[0].Luid );

    if (!AdjustTokenPrivileges( hToken, FALSE, &Priv, sizeof(Priv), &PrivOld, &cbPriv ))
    {
        CloseHandle( hToken );
        return LastNtStatus();
    }

    if (GetLastError() == ERROR_NOT_ALL_ASSIGNED)
    {
        CloseHandle( hToken );
        return LastNtStatus();
    }
    
    return STATUS_SUCCESS;
}
コード例 #20
0
		int do_execute(const std::vector<std::basic_string<CharType>>& args, boost::system::error_code& ec)
		{
			if (args.empty())
			{
				ec = make_error_code(executeplus_error::external_process_failed);

				return EXIT_FAILURE;
			}

			const std::basic_string<CharType> application = args.front();
			std::basic_ostringstream<CharType> command_line_buffer;

			for (auto it = args.begin(); it != args.end(); ++it)
			{
				if (it != args.begin())
				{
					command_line_buffer << " ";
				}

				command_line_buffer << escape_argument_if_needed(*it);
			}

			std::basic_string<CharType> command_line = command_line_buffer.str();

			return create_process(application.c_str(), &command_line[0]);
		}
コード例 #21
0
void CPwQualityEst::_EnsureInitialized()
{
	if(m_vCharTypes.size() == 0)
	{
		std::basic_string<WCHAR> strSpecial(PDCS_PRINTASCIISPEC);
		if(strSpecial.find(L' ') != strSpecial.npos) { ASSERT(FALSE); }
		else strSpecial += L' ';

		const std::basic_string<WCHAR> strHigh =
			PwCharSet::GetHighAnsiChars().ToString();

		m_vCharTypes.push_back(boost::shared_ptr<CQeCharType>(
			new CQeCharType(QE_PAT_LOWERALPHA, PDCS_LOWER_CASE, true)));
		m_vCharTypes.push_back(boost::shared_ptr<CQeCharType>(
			new CQeCharType(QE_PAT_UPPERALPHA, PDCS_UPPER_CASE, true)));
		m_vCharTypes.push_back(boost::shared_ptr<CQeCharType>(
			new CQeCharType(QE_PAT_DIGIT, PDCS_NUMERIC, true)));
		m_vCharTypes.push_back(boost::shared_ptr<CQeCharType>(
			new CQeCharType(QE_PAT_SPECIAL, strSpecial.c_str(), false)));
		m_vCharTypes.push_back(boost::shared_ptr<CQeCharType>(
			new CQeCharType(QE_PAT_HIGH, strHigh.c_str(), false)));
		m_vCharTypes.push_back(boost::shared_ptr<CQeCharType>(
			new CQeCharType(QE_PAT_OTHER, 0x10000U - (2U * 26U) - 10U -
			strSpecial.size() - strHigh.size())));
	}
}
コード例 #22
0
ファイル: fileutils.hpp プロジェクト: TheDarklingWolf/ADWIF
void write(std::ostream& stream, const std::basic_string<T>& value)
{
    StorageSize size = value.size();
    write(stream, size);
    stream.write(reinterpret_cast<const char*>(value.c_str()), value.size() * sizeof(T));
//    for (auto const & i : value)
//      stream << i;
}
コード例 #23
0
STDMETHODIMP_(LPTSTR) CKpUtilitiesImpl::GetQuotedPath(LPCTSTR lpPath)
{
	if(lpPath == NULL) return NULL;

	const std::basic_string<TCHAR> str = lpPath;
	const std::basic_string<TCHAR> strPath = SU_GetQuotedPath(str);
	return _TcsSafeDupAlloc(strPath.c_str());
}
コード例 #24
0
ファイル: regex.hpp プロジェクト: CasparCG/Client
 static bool matches(
     std::basic_string< CharT, StringTraitsT, AllocatorT > const& str,
     boost::basic_regex< CharT, ReTraitsT > const& expr,
     boost::regex_constants::match_flag_type flags = boost::regex_constants::match_default)
 {
     const CharT* p = str.c_str();
     return boost::regex_match(p, p + str.size(), expr, flags);
 }
コード例 #25
0
ファイル: event_log_registry.hpp プロジェクト: ElaraFX/boost
    bool verify_event_log_registry(std::basic_string< CharT > const& reg_key, bool force, registry_params< CharT > const& params)
    {
        typedef std::basic_string< CharT > string_type;
        typedef registry_traits< CharT > registry;

        // Open the key
        HKEY hkey = 0;
        LSTATUS res = registry::open_key(
            HKEY_LOCAL_MACHINE,
            reg_key.c_str(),
            REG_OPTION_NON_VOLATILE,
            KEY_READ,
            &hkey);
        if (res != ERROR_SUCCESS)
            return false;

        auto_hkey_close hkey_guard(hkey);

        if (force)
        {
            // Verify key values
            if (!!params.event_message_file)
            {
                string_type module_name;
                res = registry::get_value(hkey, registry::get_event_message_file_param_name(), module_name);
                if (res != ERROR_SUCCESS || module_name != params.event_message_file.get())
                    return false;
            }

            if (!!params.category_message_file)
            {
                string_type module_name;
                res = registry::get_value(hkey, registry::get_category_message_file_param_name(), module_name);
                if (res != ERROR_SUCCESS || module_name != params.category_message_file.get())
                    return false;
            }

            if (!!params.category_count)
            {
                // Set number of categories
                DWORD category_count = 0;
                res = registry::get_value(hkey, registry::get_category_count_param_name(), category_count);
                if (res != ERROR_SUCCESS || category_count != params.category_count.get())
                    return false;
            }

            if (!!params.types_supported)
            {
                // Set the supported event types
                DWORD event_types = 0;
                res = registry::get_value(hkey, registry::get_types_supported_param_name(), event_types);
                if (res != ERROR_SUCCESS || event_types != params.types_supported.get())
                    return false;
            }
        }

        return true;
    }
コード例 #26
0
inline void register_sink_factory(
    std::basic_string< CharT, TraitsT, AllocatorT > const& sink_name,
    function1<
        shared_ptr< sinks::sink< CharT > >,
        std::map< std::basic_string< CharT >, std::basic_string< CharT > > const&
    > const& factory)
{
    register_sink_factory(sink_name.c_str(), factory);
}
コード例 #27
0
ファイル: cstr.hpp プロジェクト: kadavros/stx
 cstr(const std::basic_string<char_type, CharTraits, Allocator>& s)
 {
     if (s.empty()) {
         clear();
     } else {
         buf_ = s.c_str();
         size_ = s.size();
     }
 }
コード例 #28
0
ファイル: GetWanIpAddress.cpp プロジェクト: pindumb/temp
	WinInet(const std::basic_string<TCHAR>& agent, DWORD accessType)
	{
		handle_ = InternetOpen(agent.c_str(), accessType, NULL, NULL, 0);
		
		if(handle_ == NULL)
		{
			throw std::exception("InternetOpen failed!");
		}
	}
コード例 #29
0
inline
void
teststreaming(std::string const& testname,
              temporal_type value,
              std::basic_string<charT> const& expected_result,
              const std::locale& locale)
{
    std::basic_stringstream<charT> ss;
    ss.imbue(locale);
    ss << value;

    if (!check(testname, ss.str() == expected_result))
#if !defined(BOOST_NO_STD_WSTRING)
        std::wcout << L"Expected: \"" << expected_result.c_str() << L"\"\nGot:      \"" << ss.str().c_str() << L"\"" << std::endl;
#else
        std::cout << "Expected: \"" << expected_result.c_str() << "\"\nGot:      \"" << ss.str().c_str() << L"\"" << std::endl;
#endif
}
コード例 #30
0
ファイル: regex_merge.hpp プロジェクト: doudouOUC/ndn-cpp
inline OutputIterator regex_merge(OutputIterator out,
                         Iterator first,
                         Iterator last,
                         const basic_regex<charT, traits>& e, 
                         const std::basic_string<charT>& fmt,
                         match_flag_type flags = match_default)
{
   return regex_merge(out, first, last, e, fmt.c_str(), flags);
}