当前位置: 首页>>代码示例>>C++>>正文


C++ SystemException函数代码示例

本文整理汇总了C++中SystemException函数的典型用法代码示例。如果您正苦于以下问题:C++ SystemException函数的具体用法?C++ SystemException怎么用?C++ SystemException使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了SystemException函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: sizeof

std::string EnvironmentImpl::osNameImpl()
{
	OSVERSIONINFO vi;
	vi.dwOSVersionInfoSize = sizeof(vi);
	if (GetVersionEx(&vi) == 0) throw SystemException("Cannot get OS version information");
	switch (vi.dwPlatformId)
	{
	case VER_PLATFORM_WIN32s:
		return "Windows 3.x";
	case VER_PLATFORM_WIN32_WINDOWS:
		return vi.dwMinorVersion == 0 ? "Windows 95" : "Windows 98";
	case VER_PLATFORM_WIN32_NT:
		return "Windows NT";
	default:
		return "Unknown";
	}
}
开发者ID:Alcibiades586,项目名称:roadrunner,代码行数:17,代码来源:Environment_WIN32.cpp

示例2: sizeof

std::string EnvironmentImpl::osDisplayNameImpl()
{
	OSVERSIONINFO vi;
	vi.dwOSVersionInfoSize = sizeof(vi);
	if (GetVersionEx(&vi) == 0) throw SystemException("Cannot get OS version information");
	switch(vi.dwMajorVersion)
	{
	case 6:
		switch (vi.dwMinorVersion)
		{
		case 0:
			return "Windows Vista/Server 2008";
		case 1:
			return "Windows 7/Server 2008 SP2";
		default:
			return "Unknown";
		}
	case 5:
		switch (vi.dwMinorVersion)
		{
		case 0:
			return "Windows 2000";
		case 1:
			return "Windows XP";
		case 2:
			return "Windows Server 2003/Windows Server 2003 R2";
		default:
			return "Unknown";
		}
	case 4:
		switch (vi.dwMinorVersion)
		{
		case 0:
			return "Windows 95/Windows NT 4.0";
		case 10:
			return "Windows 98";
		case 90:
			return "Windows ME";
		default:
			return "Unknown";
		}
	default:
		return "Unknown";
	}
}
开发者ID:Adoni,项目名称:WiEngine,代码行数:45,代码来源:Environment_WIN32U.cpp

示例3: UserException

/**
 * \brief Function to make a link from a given
 * \param src : the source file
 * \return the path of the link
 * Throw exception on error
 */
std::string
vishnu::mklink(const std::string& src) {

  if( ! bfs::exists(src) )  {
    throw UserException(ERRCODE_FILENOTFOUND, "SSHJobExec::mklink : "
                        "the file "+ src + " doesnot exist.");
  }
  bfs::path dest ;

  try {
    dest = bfs::unique_path("/tmp/vishnulink%%%%%%") ;
    bfs::create_symlink(src, dest) ;
  }catch (...) {
    throw SystemException(ERRCODE_SYSTEM, "SSHJobExec::mklink : "
                          "error while making a link on the file " + src + " from " + dest.string());
  }
  return dest.string() ;
}
开发者ID:Ecapo,项目名称:vishnu,代码行数:24,代码来源:utilVishnu.cpp

示例4: switch

void RWLockImpl::readLockImpl()
{
	HANDLE h[2];
	h[0] = _mutex;
	h[1] = _readEvent;
	switch (WaitForMultipleObjects(2, h, TRUE, INFINITE))
	{
	case WAIT_OBJECT_0:
	case WAIT_OBJECT_0 + 1:
		++_readers;
		ResetEvent(_writeEvent);
		ReleaseMutex(_mutex);
		poco_assert_dbg(_writers == 0);
		break;
	default:
		throw SystemException("cannot lock reader/writer lock");
	}
}
开发者ID:119,项目名称:vdc,代码行数:18,代码来源:RWLock_WIN32.cpp

示例5: throw

/**
 * Create a random access stream from a file, removing it if it already exists.
 * @param path			Path of the file to open.
 * @param access		Type of access (one of READ, WRITE, READ_WRITE).
 * @return				Opened file.
 * @throws IOException	Thrown if there is an error.
 */
io::RandomAccessStream *System::createRandomFile(
		const sys::Path& path,
		access_t access)
throw(SystemException)
{
	ASSERTP(access != READ, "file creation requires at least a write mode");
	int fd = ::open(&path.toString(), makeFlags(access) | O_CREAT | O_TRUNC, 0666);
	if(fd < 0)
		throw SystemException(errno, _ << "cannot create \"" << path << "\"");
	else
#		if defined(__unix)  || defined(__APPLE__)
			return new UnixRandomAccessStream(fd);
#		elif defined(__WIN32) || defined(__WIN64)
			return new WinRandomAccessStream(fd);
#		else
#			error "Unsupported on this OS !"
#		endif
}
开发者ID:alexjordan,项目名称:otawa,代码行数:25,代码来源:system_System.cpp

示例6: MakeFullname

void SysSemaphore::Construct(const int32_t initialCount, const int32_t maxCount, const wchar_t* pName, void* security)
{
	if (nullptr != pName)
	{
		std::wstring fullName = MakeFullname(pName);
		m_handle = CreateSemaphore(reinterpret_cast<LPSECURITY_ATTRIBUTES>(security), initialCount, maxCount, fullName.c_str());
	}
	else
	{
		m_handle = CreateSemaphore(reinterpret_cast<LPSECURITY_ATTRIBUTES>(security), initialCount, maxCount, pName);
	}


	if (nullptr == m_handle)
	{
		throw SystemException("Couldn't create a new semaphore");
	}
}
开发者ID:marmysh,项目名称:FX-Lib,代码行数:18,代码来源:SysSemaphore.cpp

示例7: parseEmfObject

void parseEmfObject(const std::string& objectSerialized, T*& object_ptr, const std::string msgComp=std::string()) {

  object_ptr = NULL;
  try {
    //CREATE DATA MODEL
    T tmpObject;
    ecore::EPackage_ptr ecorePackage = tmpObject._eClass()->getEPackage();
    ecorecpp::MetaModelRepository::_instance()->load(ecorePackage);

    //Parse the model
    ecorecpp::parser::parser parser;
    object_ptr = parser.load_str(objectSerialized)->as< T >();
  }
  catch (std::exception& e) {
    throw SystemException(ERRCODE_INVDATA, msgComp);
  }

}
开发者ID:Ecapo,项目名称:vishnu,代码行数:18,代码来源:utilClient.hpp

示例8: mapPrio

void ThreadImpl::setPriorityImpl(int prio)
{
	if (prio != _pData->prio)
	{
		_pData->prio = prio;
		_pData->policy = SCHED_OTHER;
		if (isRunningImpl())
		{
			struct sched_param par; struct MyStruct
			{

			};
			par.sched_priority = mapPrio(_pData->prio, SCHED_OTHER);
			if (pthread_setschedparam(_pData->thread, SCHED_OTHER, &par))
				throw SystemException("cannot set thread priority");
		}
	}
}
开发者ID:jacklicn,项目名称:macchina.io,代码行数:18,代码来源:Thread_POSIX.cpp

示例9: readAll

	static string readAll(int fd) {
		string result;
		char buf[1024 * 32];
		ssize_t ret;
		while (true) {
			do {
				ret = read(fd, buf, sizeof(buf));
			} while (ret == -1 && errno == EINTR);
			if (ret == 0) {
				break;
			} else if (ret == -1) {
				throw SystemException("Cannot read from socket", errno);
			} else {
				result.append(buf, ret);
			}
		}
		return result;
	}
开发者ID:ato,项目名称:passenger,代码行数:18,代码来源:ApplicationPoolTest.cpp

示例10: GetCurrentDirectoryW

std::string PathImpl::currentImpl()
{
	std::string result;
	DWORD len = GetCurrentDirectoryW(0, NULL);
	if (len > 0)
	{
		Buffer<wchar_t> buffer(len);
		DWORD n = GetCurrentDirectoryW(len, buffer.begin());
		if (n > 0 && n <= len)
		{
			UnicodeConverter::toUTF8(buffer.begin(), result);
			if (result[result.size() - 1] != '\\')
				result.append("\\");
			return result;
		}
	}
	throw SystemException("Cannot get current directory");
}
开发者ID:Adoni,项目名称:WiEngine,代码行数:18,代码来源:Path_WIN32U.cpp

示例11: defined

RWLockImpl::RWLockImpl()
{
#if defined(POCO_VXWORKS)
	// This workaround is for VxWorks 5.x where
	// pthread_mutex_init() won't properly initialize the mutex
	// resulting in a subsequent freeze in pthread_mutex_destroy()
	// if the mutex has never been used.
	std::memset(&_mutex, 0, sizeof(_mutex));
#endif
	pthread_mutexattr_t attr;
	pthread_mutexattr_init(&attr);
	if (pthread_mutex_init(&_mutex, &attr))
	{
		pthread_mutexattr_destroy(&attr);
		throw SystemException("cannot create mutex");
	}
	pthread_mutexattr_destroy(&attr);
}
开发者ID:119,项目名称:vdc,代码行数:18,代码来源:RWLock_VX.cpp

示例12: switch

bool MutexImpl::tryLockImpl()
{
	switch (WaitForSingleObject(_mutex, 0))
	{
	case WAIT_TIMEOUT:
		return false;
	case WAIT_OBJECT_0:
		if (!_recursive && _lockCount > 0)
		{
			ReleaseMutex(_mutex);
			return false;
		}
		++_lockCount;
		return true;
	default:
		throw SystemException("cannot lock mutex");
	}
}
开发者ID:cshnick,项目名称:CommunicationModel,代码行数:18,代码来源:Mutex_WINCE.cpp

示例13: switch

bool RWLockImpl::tryReadLockImpl()
{
	HANDLE h[2];
	h[0] = _mutex;
	h[1] = _readEvent;
	switch (WaitForMultipleObjects(2, h, TRUE, 1))
	{
	case WAIT_OBJECT_0:
	case WAIT_OBJECT_0 + 1:
		++_readers;
		ResetEvent(_writeEvent);
		ReleaseMutex(_mutex);
		return true;
	case WAIT_TIMEOUT:
		return false;
	default:
		throw SystemException("cannot lock reader/writer lock");
	}
}
开发者ID:carvalhomb,项目名称:tsmells,代码行数:19,代码来源:RWLock_WIN32.cpp

示例14: while

void Directory::Iterator::go(void) {
	errno = 0;
	while(true) {
		struct dirent *dirent = readdir((DIR *)dir);
		if(dirent) {
			if(cstring(dirent->d_name) != "." && cstring(dirent->d_name) != "..") {
				file = FileItem::get(path / dirent->d_name);
				return;
			}
		}
		else {
			if(errno)
				throw SystemException(errno, "file");
			else
				file = 0;
			break;
		}
	}
}
开发者ID:alexjordan,项目名称:otawa,代码行数:19,代码来源:system_Directory.cpp

示例15: _name

SharedMemoryImpl::SharedMemoryImpl(const Poco::File& file, SharedMemory::AccessMode mode, const void*):
	_name(file.path()),
	_memHandle(INVALID_HANDLE_VALUE),
	_fileHandle(INVALID_HANDLE_VALUE),
	_size(0),
	_mode(PAGE_READONLY),
	_address(0)
{
	if (!file.exists() || !file.isFile())
		throw FileNotFoundException(_name);

	_size = static_cast<DWORD>(file.getSize());

	DWORD shareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
	DWORD fileMode  = GENERIC_READ;

	if (mode == SharedMemory::AM_WRITE)
	{
		_mode = PAGE_READWRITE;
		fileMode |= GENERIC_WRITE;
	}

#if defined (POCO_WIN32_UTF8)
	std::wstring utf16name;
	UnicodeConverter::toUTF16(_name, utf16name);
	_fileHandle = CreateFileW(utf16name.c_str(), fileMode, shareMode, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
#else
	_fileHandle = CreateFileA(_name.c_str(), fileMode, shareMode, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
#endif

	if (_fileHandle == INVALID_HANDLE_VALUE)
		throw OpenFileException("Cannot open memory mapped file", _name);

	_memHandle = CreateFileMapping(_fileHandle, NULL, _mode, 0, 0, NULL);
	if (!_memHandle)
	{
		CloseHandle(_fileHandle);
		_fileHandle = INVALID_HANDLE_VALUE;
		throw SystemException("Cannot map file into shared memory", _name);
	}
	map();
}
开发者ID:Chingliu,项目名称:poco,代码行数:42,代码来源:SharedMemory_WIN32.cpp


注:本文中的SystemException函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。