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


C++ poco_assert函数代码示例

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


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

示例1: poco_assert

void Context::enableSessionCache(bool flag, const std::string& sessionIdContext)
{
	poco_assert (isForServerUse());

	if (flag)
	{
		SSL_CTX_set_session_cache_mode(_pSSLContext, SSL_SESS_CACHE_SERVER);
	}
	else
	{
		SSL_CTX_set_session_cache_mode(_pSSLContext, SSL_SESS_CACHE_OFF);
	}
	
	unsigned length = static_cast<unsigned>(sessionIdContext.length());
	if (length > SSL_MAX_SSL_SESSION_ID_LENGTH) length = SSL_MAX_SSL_SESSION_ID_LENGTH;
	int rc = SSL_CTX_set_session_id_context(_pSSLContext, reinterpret_cast<const unsigned char*>(sessionIdContext.data()), length);
	if (rc != 1) throw SSLContextException("cannot set session ID context");
}
开发者ID:RobertAcksel,项目名称:poco,代码行数:18,代码来源:Context.cpp

示例2: poco_assert

void JobManager::WakeUp(InternalJob::Pointer job, Poco::Timestamp::TimeDiff delay)
{
  poco_assert(delay >= 0); // "Scheduling delay is negative"

  {
    Poco::ScopedLock<Poco::Mutex> m_managerLock (m_mutex);
    //cannot wake up if it is not sleeping
    if (job->GetState() != Job::SLEEPING)
    return;
    DoSchedule(job, delay);
  }
  //call the pool outside sync block to avoid deadlock
  m_Pool->JobQueued();

  /// IListenerExtension only notify of wake up if immediate
  if (delay == 0)
  m_JobListeners.Awake(job.Cast<Job>());
}
开发者ID:test-fd301,项目名称:MITK,代码行数:18,代码来源:berryJobManager.cpp

示例3: poco_assert

void BundleFile::list(const std::string& path, std::vector<std::string>& files) const	
{
	poco_assert (_pArchive);
	
	files.clear();
	int depth = 0;
	std::string parent;
	if (!path.empty())
	{
		// ensure parent ends with a slash
		Path parentPath(path, Path::PATH_UNIX);
		parentPath.makeDirectory();
		parent = parentPath.toString(Path::PATH_UNIX);
	}
	ZipArchive::FileHeaders::const_iterator it;
	ZipArchive::FileHeaders::const_iterator end(_pArchive->headerEnd());
	if (path.empty())
	{
		it = _pArchive->headerBegin();
	}
	else
	{
		it = _pArchive->findHeader(parent);
		if (it != end) ++it;
		depth = Path(parent).depth();
	}
	
	std::set<std::string> fileSet;
	while (it != end && isSubdirectoryOf(it->first, parent))
	{
		Path p(it->first, Path::PATH_UNIX);
		p.makeFile();
		if (p.depth() == depth)
		{
			std::string name = p.getFileName();
			if (fileSet.find(name) == fileSet.end())
			{
				files.push_back(name);
				fileSet.insert(name);
			}
		}
		++it;
	}
}
开发者ID:JoneXie,项目名称:macchina.io,代码行数:44,代码来源:BundleFile.cpp

示例4: poco_assert

std::size_t Preparation::maxDataSize(std::size_t pos) const
{
	poco_assert (pos >= 0 && pos < _pValues.size());

	std::size_t sz = 0;
	std::size_t maxsz = getMaxFieldSize();

	try 
	{
		ODBCColumn col(_rStmt, pos);
		sz = col.length();
		if (ODBCColumn::FDT_STRING == col.type()) ++sz;
	}
	catch (StatementException&) 
	{
	}
	if (!sz || sz > maxsz) sz = maxsz;
	return sz;
}
开发者ID:BrianHoldsworth,项目名称:Poco,代码行数:19,代码来源:Preparation.cpp

示例5: poco_assert

void FileImpl::setSizeImpl(FileSizeImpl size)
{
    poco_assert (!_path.empty());

    int fd = open(_path.c_str(), O_WRONLY, S_IRWXU);
    if (fd != -1)
    {
        try
        {
            if (ftruncate(fd, size) != 0)
                handleLastErrorImpl(_path);
        }
        catch (...)
        {
            close(fd);
            throw;
        }
    }
}
开发者ID:as2120,项目名称:ZPoco,代码行数:19,代码来源:File_VX.cpp

示例6: poco_assert_dbg

int StreamConverterBuf::readFromDevice()
{
	poco_assert_dbg (_pIstr);

	if (_pos < _sequenceLength) return _buffer[_pos++];

	_pos = 0;
	_sequenceLength = 0;
	int c = _pIstr->get();
	if (c == -1) return -1;	

	poco_assert (c < 256);
	int uc;
	_buffer [0] = (unsigned char) c;
	int n = _inEncoding.queryConvert(_buffer, 1);
	int read = 1;

	while (-1 > n)
	{
		poco_assert_dbg(-n <= sizeof(_buffer));
		_pIstr->read((char*) _buffer + read, -n - read);
		read = -n;
		n = _inEncoding.queryConvert(_buffer, -n);
	}

	if (-1 >= n)
	{
		uc = _defaultChar;
		++_errors;
	}
	else
	{
		uc = n;
	}

	_sequenceLength = _outEncoding.convert(uc, _buffer, sizeof(_buffer));
	if (_sequenceLength == 0)
		_sequenceLength = _outEncoding.convert(_defaultChar, _buffer, sizeof(_buffer));
	if (_sequenceLength == 0)
		return -1;
	else
		return _buffer[_pos++];
}
开发者ID:sdottaka,项目名称:winmerge-v2,代码行数:43,代码来源:StreamConverter.cpp

示例7: _year

DateTime::DateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, int microsecond):
	_year(year),
	_month(month),
	_day(day),
	_hour(hour),
	_minute(minute),
	_second(second),
	_millisecond(millisecond),
	_microsecond(microsecond)
{
	poco_assert (year >= 0 && year <= 9999);
	poco_assert (month >= 1 && month <= 12);
	poco_assert (day >= 1 && day <= daysOfMonth(year, month));
	poco_assert (hour >= 0 && hour <= 23);
	poco_assert (minute >= 0 && minute <= 59);
	poco_assert (second >= 0 && second <= 59);
	poco_assert (millisecond >= 0 && millisecond <= 999);
	poco_assert (microsecond >= 0 && microsecond <= 999);
	
	_utcTime = toUtcTime(toJulianDay(year, month, day)) + 10*(hour*Timespan::HOURS + minute*Timespan::MINUTES + second*Timespan::SECONDS + millisecond*Timespan::MILLISECONDS + microsecond);
}
开发者ID:RangelReale,项目名称:sandbox,代码行数:21,代码来源:DateTime.cpp

示例8: _n

SemaphoreImpl::SemaphoreImpl(int n, int max): _n(n), _max(max)
{
	poco_assert (n >= 0 && max > 0 && n <= max);

#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
	if (pthread_mutex_init(&_mutex, NULL))
		throw SystemException("cannot create semaphore (mutex)");

#if defined(POCO_HAVE_MONOTONIC_PTHREAD_COND_TIMEDWAIT)
	pthread_condattr_t attr;
	if (pthread_condattr_init(&attr))
	{
		pthread_mutex_destroy(&_mutex);
		throw SystemException("cannot create semaphore (condition attribute)");
	}
	if (pthread_condattr_setclock(&attr, CLOCK_MONOTONIC))
    {
		pthread_condattr_destroy(&attr);
		pthread_mutex_destroy(&_mutex);
		throw SystemException("cannot create semaphore (condition attribute clock)");
    }
	if (pthread_cond_init(&_cond, &attr))
	{
		pthread_condattr_destroy(&attr);
		pthread_mutex_destroy(&_mutex);
		throw SystemException("cannot create semaphore (condition)");
	}
	pthread_condattr_destroy(&attr);
#else
	if (pthread_cond_init(&_cond, NULL))
	{
		pthread_mutex_destroy(&_mutex);
		throw SystemException("cannot create semaphore (condition)");
	}
#endif
}
开发者ID:Bjoe,项目名称:poco,代码行数:42,代码来源:Semaphore_POSIX.cpp

示例9: _minCapacity

ThreadPool::ThreadPool(int minCapacity,
	int maxCapacity,
	int idleTime,
	int stackSize): 
	_minCapacity(minCapacity), 
	_maxCapacity(maxCapacity), 
	_idleTime(idleTime),
	_serial(0),
	_age(0),
	_stackSize(stackSize)
{
	poco_assert (minCapacity >= 1 && maxCapacity >= minCapacity && idleTime > 0);

	for (int i = 0; i < _minCapacity; i++)
	{
		PooledThread* pThread = createThread();
		_threads.push_back(pThread);
		pThread->start();
	}
}
开发者ID:PsyCommando,项目名称:ppmdu,代码行数:20,代码来源:ThreadPool.cpp

示例10: lock

AbstractSession& SimpleSessionStore::getSession(const std::string& sessionId)
{
    std::unique_lock<std::mutex> lock(_mutex);

    SessionMap::iterator sessionsIter = _sessionMap.find(sessionId);

    if (sessionsIter != _sessionMap.end())
    {
        // This must be valid b/c it's designed that way and we
        // need to return a reference.
        poco_assert(sessionsIter->second);

        return (*sessionsIter->second);
    }
    else
    {

        throw Poco::InvalidAccessException("Session " + sessionId + " not found.");
    }
}
开发者ID:ChulseungYoo,项目名称:ofxHTTP,代码行数:20,代码来源:SessionStore.cpp

示例11: _in

Decompress::Decompress(std::istream& in, const Poco::Path& outputDir, bool flattenDirs, bool keepIncompleteFiles):
	_in(in),
	_outDir(outputDir),
	_flattenDirs(flattenDirs),
	_keepIncompleteFiles(keepIncompleteFiles),
	_mapping()
{
	_outDir.makeAbsolute();
	_outDir.makeDirectory();
	poco_assert (_in.good());
	Poco::File tmp(_outDir);
	if (!tmp.exists())
	{
		tmp.createDirectories();
	}
	if (!tmp.isDirectory())
		throw Poco::IOException("Failed to create/open directory: " + _outDir.toString());
	EOk += Poco::Delegate<Decompress, std::pair<const ZipLocalFileHeader, const Poco::Path> >(this, &Decompress::onOk);

}
开发者ID:12307,项目名称:poco,代码行数:20,代码来源:Decompress.cpp

示例12: poco_assert

void ZipLocalFileHeader::init(	const Poco::Path& fName, 
								ZipCommon::CompressionMethod cm, 
								ZipCommon::CompressionLevel cl)
{
	poco_assert (_fileName.empty());
	setSearchCRCAndSizesAfterData(false);
	Poco::Path fileName(fName);
	fileName.setDevice(""); // clear device!
	setFileName(fileName.toString(Poco::Path::PATH_UNIX), fileName.isDirectory());
	setRequiredVersion(2, 0);
	if (fileName.isFile())
	{
		setCompressionMethod(cm);
		setCompressionLevel(cl);
	}
	else
		setCompressionMethod(ZipCommon::CM_STORE);
    
    _rawHeader[GENERAL_PURPOSE_POS+1] |= 0x08; // Set "language encoding flag" to indicate that filenames and paths are in UTF-8.
}
开发者ID:Aahart911,项目名称:ClickHouse,代码行数:20,代码来源:ZipLocalFileHeader.cpp

示例13: poco_assert

bool FileImpl::existsImpl() const
{
	poco_assert (!_path.empty());

	DWORD attr = GetFileAttributes(_path.c_str());
	if (attr == 0xFFFFFFFF)
	{
		switch (GetLastError())
		{
		case ERROR_FILE_NOT_FOUND:
		case ERROR_PATH_NOT_FOUND:
		case ERROR_NOT_READY:
		case ERROR_INVALID_DRIVE:
			return false;
		default:
			handleLastErrorImpl(_path);
		}
	}
	return true;
}
开发者ID:9drops,项目名称:poco,代码行数:20,代码来源:File_WIN32.cpp

示例14: poco_assert

void FileImpl::setExecutableImpl(bool flag)
{
	poco_assert (!_path.empty());

	struct stat st;
	if (stat(_path.c_str(), &st) != 0) 
		handleLastErrorImpl(_path);
	mode_t mode;
	if (flag)
	{
		mode = st.st_mode | S_IXUSR;
	}
	else
	{
		mode_t wmask = S_IXUSR | S_IXGRP | S_IXOTH;
		mode = st.st_mode & ~wmask;
	}
	if (chmod(_path.c_str(), mode) != 0) 
		handleLastErrorImpl(_path);
}
开发者ID:12307,项目名称:poco,代码行数:20,代码来源:File_UNIX.cpp

示例15: it

int TextConverter::convert(const std::string& source, std::string& destination, Transform trans)
{
	int errors = 0;
	TextIterator it(source, _inEncoding);
	TextIterator end(source);
	unsigned char buffer[TextEncoding::MAX_SEQUENCE_LENGTH];

	while (it != end)
	{
		int c = *it;
		if (c == -1) { ++errors; c = _defaultChar; }
		c = trans(c);
		int n = _outEncoding.convert(c, buffer, sizeof(buffer));
		if (n == 0) n = _outEncoding.convert(_defaultChar, buffer, sizeof(buffer));
		poco_assert (n <= sizeof(buffer));
		destination.append((const char*) buffer, n);
		++it;
	}
	return errors;
}
开发者ID:Victorcasas,项目名称:georest,代码行数:20,代码来源:TextConverter.cpp


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