本文整理汇总了C++中boost::scoped_array::get方法的典型用法代码示例。如果您正苦于以下问题:C++ scoped_array::get方法的具体用法?C++ scoped_array::get怎么用?C++ scoped_array::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::scoped_array
的用法示例。
在下文中一共展示了scoped_array::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: info
//-----------------------------------------------------------------------------
void dolfin::info(std::string msg, ...)
{
if (!LogManager::logger.is_active())
return; // optimization
read(buffer.get(), msg);
LogManager::logger.log(buffer.get());
}
示例2: setupInput
/** Sets up the spline object by with the parameters and attributes
*
* @param x :: The array of x values defining the spline
* @param y :: The array of y values defining the spline
* @param n :: The size of the arrays
*/
void CubicSpline::setupInput(boost::scoped_array<double> &x,
boost::scoped_array<double> &y, int n) const {
// Populate data points from the input attributes and parameters
bool xSortFlag = false;
for (int i = 0; i < n; ++i) {
std::string num = boost::lexical_cast<std::string>(i);
std::string xName = "x" + num;
std::string yName = "y" + num;
x[i] = getAttribute(xName).asDouble();
// if x[i] is out of order with its neighbours
if (i > 1 && i < n && (x[i - 1] < x[i - 2] || x[i - 1] > x[i])) {
xSortFlag = true;
}
y[i] = getParameter(yName);
}
// sort the data points if necessary
if (xSortFlag) {
g_log.warning() << "Spline x parameters are not in ascending order. Values "
"will be sorted." << std::endl;
std::sort(x.get(), x.get() + n);
}
// pass values to GSL objects
initGSLObjects(x, y, n);
m_recalculateSpline = false;
}
示例3: deprecation
//-----------------------------------------------------------------------------
void dolfin::deprecation(std::string feature,
std::string version,
std::string message, ...)
{
read(buffer.get(), message);
LogManager::logger.deprecation(feature, version, buffer.get());
}
示例4: dolfin_error
//-----------------------------------------------------------------------------
void dolfin::dolfin_error(std::string location,
std::string task,
std::string reason, ...)
{
read(buffer.get(), reason);
LogManager::logger.dolfin_error(location, task, buffer.get());
}
示例5: __debug
//-----------------------------------------------------------------------------
void dolfin::__debug(std::string file, unsigned long line,
std::string function, std::string format, ...)
{
read(buffer.get(), format);
std::ostringstream ost;
ost << file << ":" << line << " in " << function << "()";
std::string msg = std::string(buffer.get()) + " [at " + ost.str() + "]";
LogManager::logger.__debug(msg);
}
示例6: defined
inline
systembuf::systembuf(handle_type h, std::size_t bufsize) :
m_handle(h),
m_bufsize(bufsize),
m_read_buf(new char[bufsize]),
m_write_buf(new char[bufsize])
{
#if defined(BOOST_PROCESS_WIN32_API)
BOOST_ASSERT(m_handle != INVALID_HANDLE_VALUE);
#else
BOOST_ASSERT(m_handle >= 0);
#endif
BOOST_ASSERT(m_bufsize > 0);
setp(m_write_buf.get(), m_write_buf.get() + m_bufsize);
}
示例7: if
inline LogCodec::int_type LogCodec::consumeVoidsAndComments(streambuf_type *buf_ptr)
{
int_type c = buf_ptr->sgetc();
char * const read_buf = m_read_buf.get();
char * read_ptr;
while (!traits_type::eq_int_type(c, traits_type::eof())) {
if (m_field_split.find(c) != std::string::npos || m_event_split.find(c) != std::string::npos) {
c = buf_ptr->snextc();
} else if (m_comment_chars.find(c) != std::string::npos) {
// ignore comment line (sorta...)
read_ptr = read_buf;
do {
// check for end of line
if (m_event_split.find(c) != std::string::npos)
break;
// read in the comment in case it matters...
if (read_ptr < m_read_end)
*(read_ptr++) = c;
// get the next character
c = buf_ptr->snextc();
} while (!traits_type::eq_int_type(c, traits_type::eof()));
*read_ptr = '\0';
if (m_handle_elf_headers) {
// check if it is an ELF format change
read_buf[FIELDS_ELF_HEADER.size()] = '\0';
if (FIELDS_ELF_HEADER == read_buf)
changeELFFormat(read_buf + FIELDS_ELF_HEADER.size() + 1);
}
} else {
break;
}
}
return c;
}
示例8: defined
inline Matrix::row_iterator Matrix::row_end(Size i) {
#if defined(QL_EXTRA_SAFETY_CHECKS)
QL_REQUIRE(i<rows_,
"row index (" << i << ") must be less than " << rows_ <<
": matrix cannot be accessed out of range");
#endif
return data_.get()+columns_*(i+1);
}
示例9: column_iterator
inline Matrix::column_iterator Matrix::column_end(Size i) {
#if defined(QL_EXTRA_SAFETY_CHECKS)
QL_REQUIRE(i<columns_,
"column index (" << i << ") must be less than " << columns_ <<
": matrix cannot be accessed out of range");
#endif
return column_iterator(data_.get()+i+rows_*columns_,columns_);
}
示例10: ensureLength
void FileAllocator::ensureLength(int fd , long size) {
#if !defined(_WIN32)
if (useSparseFiles(fd)) {
LOG(1) << "using ftruncate to create a sparse file" << endl;
int ret = ftruncate(fd, size);
uassert(16063, "ftruncate failed: " + errnoWithDescription(), ret == 0);
return;
}
#endif
#if defined(__linux__)
int ret = posix_fallocate(fd,0,size);
if ( ret == 0 )
return;
log() << "FileAllocator: posix_fallocate failed: " << errnoWithDescription( ret ) << " falling back" << endl;
#endif
off_t filelen = lseek( fd, 0, SEEK_END );
if ( filelen < size ) {
if (filelen != 0) {
stringstream ss;
ss << "failure creating new datafile; lseek failed for fd " << fd << " with errno: " << errnoWithDescription();
uassert( 10440 , ss.str(), filelen == 0 );
}
// Check for end of disk.
uassert( 10441 , str::stream() << "Unable to allocate new file of size " << size << ' ' << errnoWithDescription(),
size - 1 == lseek(fd, size - 1, SEEK_SET) );
uassert( 10442 , str::stream() << "Unable to allocate new file of size " << size << ' ' << errnoWithDescription(),
1 == write(fd, "", 1) );
// File expansion is completed here. Do not do the zeroing out on OS-es where there
// is no risk of triggering allocation-related bugs such as
// http://support.microsoft.com/kb/2731284.
//
if (!ProcessInfo::isDataFileZeroingNeeded()) {
return;
}
lseek(fd, 0, SEEK_SET);
const long z = 256 * 1024;
const boost::scoped_array<char> buf_holder (new char[z]);
char* buf = buf_holder.get();
memset(buf, 0, z);
long left = size;
while ( left > 0 ) {
long towrite = left;
if ( towrite > z )
towrite = z;
int written = write( fd , buf , towrite );
uassert( 10443 , errnoWithPrefix("FileAllocator: file write failed" ), written > 0 );
left -= written;
}
}
}
示例11: TaskId
TaskId(std::string const & workTitle, uint32_t id,
boost::scoped_array<uint8_t> const & taskData,
size_t taskDataSize) :
m_workId(workTitle, id),
m_taskData(new uint8_t[taskDataSize]),
m_taskDataSize(taskDataSize)
{
memcpy(m_taskData.get(), taskData.get(), taskDataSize);
}
示例12: eof
inline
systembuf::int_type
systembuf::underflow(void)
{
BOOST_ASSERT(gptr() >= egptr());
bool ok;
#if defined(BOOST_PROCESS_WIN32_API)
DWORD cnt;
BOOL res = ::ReadFile(m_handle, m_read_buf.get(), (DWORD)m_bufsize, &cnt, NULL);
ok = (res && cnt > 0);
#else
ssize_t cnt = ::read(m_handle, m_read_buf.get(), m_bufsize);
ok = (cnt != -1 && cnt != 0);
#endif
if (!ok)
return traits_type::eof();
else {
setg(m_read_buf.get(), m_read_buf.get(), m_read_buf.get() + cnt);
return traits_type::to_int_type(*gptr());
}
}
示例13: ensureLength
void FileAllocator::ensureLength(int fd , long size) {
#if !defined(_WIN32)
if (useSparseFiles(fd)) {
LOG(1) << "using ftruncate to create a sparse file" << endl;
int ret = ftruncate(fd, size);
uassert(16063, "ftruncate failed: " + errnoWithDescription(), ret == 0);
return;
}
#endif
#if defined(__linux__)
int ret = posix_fallocate(fd,0,size);
if ( ret == 0 )
return;
log() << "FileAllocator: posix_fallocate failed: " << errnoWithDescription( ret ) << " falling back" << endl;
#endif
off_t filelen = lseek( fd, 0, SEEK_END );
if ( filelen < size ) {
if (filelen != 0) {
stringstream ss;
ss << "failure creating new datafile; lseek failed for fd " << fd << " with errno: " << errnoWithDescription();
uassert( 10440 , ss.str(), filelen == 0 );
}
// Check for end of disk.
uassert( 10441 , str::stream() << "Unable to allocate new file of size " << size << ' ' << errnoWithDescription(),
size - 1 == lseek(fd, size - 1, SEEK_SET) );
uassert( 10442 , str::stream() << "Unable to allocate new file of size " << size << ' ' << errnoWithDescription(),
1 == write(fd, "", 1) );
lseek(fd, 0, SEEK_SET);
const long z = 256 * 1024;
const boost::scoped_array<char> buf_holder (new char[z]);
char* buf = buf_holder.get();
memset(buf, 0, z);
long left = size;
while ( left > 0 ) {
long towrite = left;
if ( towrite > z )
towrite = z;
int written = write( fd , buf , towrite );
uassert( 10443 , errnoWithPrefix("FileAllocator: file write failed" ), written > 0 );
left -= written;
}
}
}
示例14: _InitBCrypt
HRESULT CKeyTransformBCrypt::_InitBCrypt(BCRYPT_ALG_HANDLE& hAes, BCRYPT_KEY_HANDLE& hKey,
boost::scoped_array<UCHAR>& pKeyObj, const BYTE* pbKey32)
{
if(m_lpBCryptOpenAlgorithmProvider(&hAes, BCRYPT_AES_ALGORITHM, NULL, 0) != 0)
{
ASSERT(FALSE);
return E_FAIL;
}
DWORD dwKeyObjLen = 0;
ULONG uResult = 0;
if(m_lpBCryptGetProperty(hAes, BCRYPT_OBJECT_LENGTH, (PUCHAR)&dwKeyObjLen,
sizeof(DWORD), &uResult, 0) != 0) KTBC_FAIL;
if(dwKeyObjLen == 0) KTBC_FAIL;
pKeyObj.reset(new UCHAR[dwKeyObjLen]);
if(m_lpBCryptSetProperty(hAes, BCRYPT_CHAINING_MODE, (PUCHAR)BCRYPT_CHAIN_MODE_ECB,
static_cast<ULONG>((wcslen(BCRYPT_CHAIN_MODE_ECB) + 1) * sizeof(wchar_t)), 0) != 0)
KTBC_FAIL;
BCRYPT_KEY_DATA_BLOB_32 keyBlob;
ZeroMemory(&keyBlob, sizeof(BCRYPT_KEY_DATA_BLOB_32));
keyBlob.dwMagic = BCRYPT_KEY_DATA_BLOB_MAGIC;
keyBlob.dwVersion = BCRYPT_KEY_DATA_BLOB_VERSION1;
keyBlob.cbKeyData = 32;
memcpy(keyBlob.pbData, pbKey32, 32);
// if(m_lpBCryptGenerateSymmetricKey(hAes, &hKey, (PUCHAR)pKeyObj.get(),
// dwKeyObjLen, const_cast<PUCHAR>(pbKey32), 32, 0) != 0) KTBC_FAIL;
if(m_lpBCryptImportKey(hAes, NULL, BCRYPT_KEY_DATA_BLOB, &hKey,
pKeyObj.get(), dwKeyObjLen, (PUCHAR)&keyBlob,
sizeof(BCRYPT_KEY_DATA_BLOB_32), 0) != 0) KTBC_FAIL;
#ifdef _DEBUG
DWORD dwKeyLen = 0;
VERIFY(m_lpBCryptGetProperty(hKey, BCRYPT_KEY_STRENGTH, (PUCHAR)&dwKeyLen,
sizeof(DWORD), &uResult, 0) == 0);
VERIFY(dwKeyLen == 256);
BCRYPT_ALG_HANDLE hRef = NULL;
VERIFY(m_lpBCryptGetProperty(hKey, BCRYPT_PROVIDER_HANDLE, (PUCHAR)&hRef,
sizeof(BCRYPT_ALG_HANDLE), &uResult, 0) == 0);
VERIFY(hRef == hAes);
#endif
return S_OK;
}
示例15: splitAudioData
void AudioResampleImpl::splitAudioData(AudioData & data, boost::scoped_array<char*> & split) const
{
auto dataFormat = data.format();
if (dataFormat.isPlanar())
{
/// Для планарного формата необходимо представить данные из result
const int numChannels = dataFormat.channelCount();
split.reset(new char*[numChannels]);
split_ref(data.begin(), data.end(), data.numBytes() / numChannels, split.get());
}
else
{
/// Interleaved данные помещаются в один массив
split.reset(new char*[1]);
split[0] = data.data();
}
}