本文整理汇总了C++中ArrayPtr类的典型用法代码示例。如果您正苦于以下问题:C++ ArrayPtr类的具体用法?C++ ArrayPtr怎么用?C++ ArrayPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ArrayPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: recordLastError
bool BaseExecutionContext::onFatalError(const Exception &e) {
recordLastError(e);
const char *file = NULL;
int line = 0;
if (RuntimeOption::InjectedStackTrace) {
const ExtendedException *ee = dynamic_cast<const ExtendedException *>(&e);
if (ee) {
ArrayPtr bt = ee->getBackTrace();
if (!bt->empty()) {
Array top = bt->rvalAt(0).toArray();
if (top.exists("file")) file = top.rvalAt("file").toString();
if (top.exists("line")) line = top.rvalAt("line");
}
}
}
if (RuntimeOption::AlwaysLogUnhandledExceptions) {
Logger::Log(Logger::LogError, "HipHop Fatal error: ", e, file, line);
}
bool handled = false;
if (RuntimeOption::CallUserHandlerOnFatals) {
int errnum = ErrorConstants::FATAL_ERROR;
handled = callUserErrorHandler(e, errnum, true);
}
if (!handled && !RuntimeOption::AlwaysLogUnhandledExceptions) {
Logger::Log(Logger::LogError, "HipHop Fatal error: ", e, file, line);
}
return handled;
}
示例2: getSpecialFolder
// YOU must free the returned string
char * getSpecialFolder (int nFolder, HWND hWnd)
{
LPMALLOC pMalloc;
LPITEMIDLIST pidl;
ArrayPtr<char> str = new char [MAX_PATH + 30];
if (str == 0)
throw AppException (WHERE, ERR_OUT_OF_MEMORY);
if (FAILED (SHGetMalloc (&pMalloc)))
return NULL;
if (FAILED (SHGetSpecialFolderLocation (hWnd, nFolder, &pidl))) {
pMalloc->Release ();
return NULL;
}
if (SHGetPathFromIDList (pidl, str) != TRUE) {
pMalloc->Free (pidl);
pMalloc->Release ();
return NULL;
}
pMalloc->Free (pidl);
pMalloc->Release ();
return str.detach ();
}
示例3: recordAutoPtr
void RecordHandler::handle(StationData* stationData, Record* record) {
RecordPtr recordAutoPtr(record);
if ( stationData->gmGain == 0 ) return;
if ( !record->data() ) return;
int dataSize = record->data()->size();
if ( dataSize <= 0 ) return;
ArrayPtr array = record->data()->copy(Array::DOUBLE);
double* data = static_cast<double*>(const_cast<void*>(array->data()));
if ( !data ) return;
stationData->gmFilter->setSamplingFrequency(record->samplingFrequency());
stationData->gmFilter->apply(dataSize, data);
double* begin = data;
double* maximumSample = std::max_element(begin, data + dataSize,
std::ptr_fun(RecordHandlerCompare));
*maximumSample = fabs(*maximumSample);
if ( stationData->gmMaximumSample < *maximumSample ||
Core::Time::GMT() - stationData->gmSampleReceiveTime > _sampleLifespan ) {
stationData->gmSampleReceiveTime = Core::Time::GMT();
stationData->gmMaximumSample= *maximumSample;
}
try { stationData->gmRecordReceiveTime = record->endTime(); }
catch ( Core::ValueException& ) { stationData->gmRecordReceiveTime = Core::Time::GMT(); }
double velocity = stationData->gmMaximumSample / stationData->gmGain * 1E9;
stationData->gmColor = calculateColorFromVelocity(velocity);
}
示例4: displayArray
//-----------------------------------------------------------------------------
// Tools::displayArray
//-----------------------------------------------------------------------------
std::string Tools::displayArray( const ArrayPtr& arr, int maxCell )
{
ArrayIterator begin = arr->begin();
ArrayIterator end = arr->end();
return Tools::scanValues( begin, end, maxCell );
}
示例5: as_push
static Variable as_push(AVM &avm){
ArrayPtr array = avm.getRegister(1).as<Array>();
if (!array)
throw Common::Exception("Array::pop this is not an Array object");
array->push(avm.getRegister(2));
return Variable();
}
示例6: toValue
Value toValue( const math::Vec3f &vec )
{
Value v = Value::createArray();
ArrayPtr a = v.asArray();
for( int i=0;i<3;++i )
a->append( Value::create<float>(vec[i]) );
return v;
}
示例7: displayValues
//-----------------------------------------------------------------------------
// Tools::displayValues
//-----------------------------------------------------------------------------
std::string Tools::displayValues(const ArrayPtr& array)
{
std::cout<<"Entering Tools::displayValues"<<std::endl;
std::string str;
ArrayIterator begin = array->begin();
ArrayIterator end = array->end();
str = scanValues(begin, end, 15);
std::cout<<"Leaving Tools::displayValues"<<std::endl;
return str;
}
示例8: SYNC_VM_REGS_SCOPED
void BaseExecutionContext::handleError(const std::string &msg,
int errnum,
bool callUserHandler,
ErrorThrowMode mode,
const std::string &prefix) {
SYNC_VM_REGS_SCOPED();
int newErrorState = ErrorRaised;
switch (getErrorState()) {
case ErrorRaised:
case ErrorRaisedByUserHandler:
return;
case ExecutingUserHandler:
newErrorState = ErrorRaisedByUserHandler;
break;
default:
break;
}
ErrorStateHelper esh(this, newErrorState);
ExtendedException ee(msg);
recordLastError(ee, errnum);
bool handled = false;
if (callUserHandler) {
handled = callUserErrorHandler(ee, errnum, false);
}
if (mode == AlwaysThrow || (mode == ThrowIfUnhandled && !handled)) {
try {
if (!Eval::Debugger::InterruptException(String(msg))) return;
} catch (const Eval::DebuggerClientExitException &e) {}
throw FatalErrorException(msg.c_str());
}
if (!handled &&
(RuntimeOption::NoSilencer ||
(getErrorReportingLevel() & errnum) != 0)) {
try {
if (!Eval::Debugger::InterruptException(String(msg))) return;
} catch (const Eval::DebuggerClientExitException &e) {}
const char *file = NULL;
int line = 0;
if (RuntimeOption::InjectedStackTrace) {
ArrayPtr bt = ee.getBackTrace();
if (!bt->empty()) {
Array top = bt->rvalAt(0).toArray();
if (top.exists("file")) file = top.rvalAt("file").toString();
if (top.exists("line")) line = top.rvalAt("line");
}
}
Logger::Log(Logger::LogError, prefix.c_str(), ee, file, line);
}
}
示例9: nextChunkSize
Arena::Arena(ArrayPtr<byte> scratch)
: nextChunkSize(kj::max(sizeof(ChunkHeader), scratch.size())) {
if (scratch.size() > sizeof(ChunkHeader)) {
ChunkHeader* chunk = reinterpret_cast<ChunkHeader*>(scratch.begin());
chunk->end = scratch.end();
chunk->pos = reinterpret_cast<byte*>(chunk + 1);
chunk->next = nullptr; // Never actually observed.
// Don't place the chunk in the chunk list because it's not ours to delete. Just make it the
// current chunk so that we'll allocate from it until it is empty.
currentChunk = chunk;
}
}
示例10: flushUnusedGeometry
void GeometryManager::flushUnusedGeometry()
{
ArrayPtr <GeometryInfo> validGeometry;
for (size_t i = 0; i < geometryCollection.length(); i++)
if (geometryCollection(i)->getUserCount() > 0)
validGeometry.append(geometryCollection(i));
else
{
deleteObject(geometryCollection(i)->getMedia());
deleteObject(geometryCollection(i));
}
geometryCollection = validGeometry;
}
示例11: isValid
int ArrayPtr::operator - ( ArrayPtr _ptr ) const
{
assert( isValid() );
assert( _ptr.isValid() );
assert( sameArray( _ptr ) );
return m_currentPosition - _ptr.m_currentPosition;
}
示例12: flushUnusedTextures
void TexturesManager::flushUnusedTextures()
{
ArrayPtr <TextureInfo> validTextures;
size_t i;
unsigned int textureID;
for (i = 0; i < textureCollection.length(); i++)
if (textureCollection(i)->getUserCount() > 0)
validTextures.append(textureCollection(i));
else
{
textureID = textureCollection(i)->getMedia();
glDeleteTextures(1, &textureID);
deleteObject(textureCollection(i));
}
textureCollection.clear();
textureCollection = validTextures;
}
示例13: switch
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
GenericRecord *Decimation::convert(Record *rec) {
if ( rec->data() == NULL ) return NULL;
GenericRecord *out;
switch ( rec->dataType() ) {
case Array::CHAR:
case Array::INT:
case Array::FLOAT:
case Array::DOUBLE:
out = createDecimatedRecord(rec);
break;
default:
return NULL;
}
ArrayPtr data = rec->data()->copy(_dataType);
out->setData(data.get());
return out;
}
示例14: Vector3
/* ------------------------------------------------------- */
void SphereVolume::computeFromData(const Ptr<VertexData>& vdata)
{
m_radius = 0.0f;
m_center = Vector3(0.0f, 0.0f, 0.0f);
float curDistance = 0.0f;
ArrayPtr<GeometryVertex> vertices = vdata->getGeometryData();
for (int i = 0; i < vertices.size(); i++)
{
m_center += vertices[i].position;
}
m_center /= vertices.size();
for (int i = 0; i < vertices.size(); i++)
{
curDistance = (vertices[i].position-m_center).squaredLength();
if (curDistance > m_radius)
{
m_radius = curDistance;
}
}
m_radius = Math<float>::Sqrt(m_radius);
}
示例15: array_reserve
void array_reserve(ArrayPtr array, uint32_t new_size) {
array->reserve(new_size);
}