本文整理汇总了C++中ArrayOf类的典型用法代码示例。如果您正苦于以下问题:C++ ArrayOf类的具体用法?C++ ArrayOf怎么用?C++ ArrayOf使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ArrayOf类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: printf
/*
* Ԥ�ڽ��: OK
*
* ���з�ʽ: clPushbackReader.ecx 8
*
*/
int CTest::TestReadBufferEx(int argc,char *argv[])
{
ICharArrayReader * ir;
ArrayOf<Char8>* buffer = ArrayOf<Char8>::Alloc(1024);
if (buffer == NULL) return E_OUT_OF_MEMORY_ERROR;
const char * str = (const char*) m_text;
buffer->Copy((Char8*) str, 1024);
ECode rt = CCharArrayReader::New(buffer, &ir);
if (rt == 0) {
rt = CPushbackReader::New((IReader*)ir, &m_pr);
}
Int32 number;
ArrayOf<Char8> *buf = ArrayOf<Char8>::Alloc(1024);
if (0 == rt) {
rt = m_pr->ReadBufferEx(0, 1, buf, &number);
}
if (0 == rt) {
printf("test 8:OK\n");
}
else {
printf("test 8 ERR: rt = %d\n", rt);
}
if(ir) ir->Release();
if(m_pr) m_pr->Release();
ArrayOf<Char8>::Free(buffer);
ArrayOf<Char8>::Free(buf);
return 0;
}
示例2: ObtainAttributes
ECode CResources::ObtainAttributes(
/* [in] */ IAttributeSet* set,
/* [in] */ const ArrayOf<Int32>& attrs,
/* [out] */ ITypedArray** array)
{
VALIDATE_NOT_NULL(set);
VALIDATE_NOT_NULL(array);
*array = NULL;
Int32 len = attrs.GetLength();
FAIL_RETURN(GetCachedStyledAttributes(len, array));
// XXX note that for now we only work with compiled XML files.
// To support generic XML files we will need to manually parse
// out the attributes from the XML file (applying type information
// contained in the resources and such).
AutoPtr<CTypedArray> a = (CTypedArray*)*array;
AutoPtr<XmlBlock::Parser> parser = (XmlBlock::Parser*)set;
mAssets->RetrieveAttributes(
parser->mParseState, attrs, *a->mData, *a->mIndices);
a->mRsrcs = attrs.Clone();
a->mXml = parser;
return NOERROR;
}
示例3: write
virtual bool write(
/* [in] */ const void* buffer,
/* [in] */ size_t size)
{
ArrayOf<Byte>* storage = mByteArray;
while (size > 0) {
size_t requested = size;
if (requested > (size_t)mCapacity) {
requested = mCapacity;
}
memcpy(storage->GetPayload(), buffer, requested);
ECode ec = mOutputStream->Write(storage, 0, requested);
if (FAILED(ec)) {
SkDebugf("------- write threw an exception\n");
return false;
}
buffer = (void*)((char*)buffer + requested);
size -= requested;
mBytesWritten += requested;
}
return true;
}
示例4: NativePutBlob
Boolean CursorWindow::NativePutBlob(
/* [in] */ const ArrayOf<Byte>& value,
/* [in] */ Int32 row,
/* [in] */ Int32 col)
{
NativeCursorWindow* window = mNativeWindow;
field_slot_t* fieldSlot = window->getFieldSlotWithCheck(row, col);
if (fieldSlot == NULL) {
// LOG_WINDOW(" getFieldSlotWithCheck error ");
return FALSE;
}
Int32 len = value.GetLength();
Int32 offset = window->alloc(len);
if (!offset) {
// LOG_WINDOW("Failed allocating %u bytes", len);
return FALSE;
}
Byte* bytes = value.GetPayload();
window->copyIn(offset, (uint8_t const *)bytes, len);
// This must be updated after the call to alloc(), since that
// may move the field around in the window
fieldSlot->type = FIELD_TYPE_BLOB;
fieldSlot->data.buffer.offset = offset;
fieldSlot->data.buffer.size = len;
// LOG_WINDOW("%d,%d is BLOB with %u bytes @ %d", row, col, len, offset);
return TRUE;
}
示例5: StartListening
ECode CAppWidgetHost::StartListening()
{
ArrayOf<Int32>* updatedIds;
AutoPtr<IObjectContainer> updatedViews;
//try {
if (mCapsuleName.IsNull()) {
mContext->GetCapsuleName(&mCapsuleName);
}
ECode ec = sService->StartListening(mCallbacks, mCapsuleName, mHostId,
(IObjectContainer**)&updatedViews, &updatedIds);
if (FAILED(ec)) {
return ec;
}
// }
// catch (RemoteException e) {
// throw new RuntimeException("system server dead?", e);
// }
AutoPtr<IObjectEnumerator> enumerator;
updatedViews->GetObjectEnumerator((IObjectEnumerator**)&enumerator);
Boolean hasNext;
for (Int32 i = 0; i < updatedIds->GetLength(); i++) {
AutoPtr<IRemoteViews> views;
enumerator->MoveNext(&hasNext);
if (hasNext) {
enumerator->Current((IInterface**)&views);
}
UpdateAppWidgetView((*updatedIds)[i], views);
}
return NOERROR;
}
示例6: ReadSummary
/// Read the summary of this alias block from disk. Since the audio data
/// is elsewhere, this consists of reading the entire summary file.
/// Fill with zeroes and return false if data are unavailable for any reason.
///
/// @param *data The buffer where the summary data will be stored. It must
/// be at least mSummaryInfo.totalSummaryBytes long.
bool ODDecodeBlockFile::ReadSummary(ArrayOf<char> &data)
{
//I dont think we need to add a mutex here because only the main thread changes filenames and calls ReadSummary
if(IsSummaryAvailable())
return SimpleBlockFile::ReadSummary(data);
data.reinit( mSummaryInfo.totalSummaryBytes );
memset(data.get(), 0, mSummaryInfo.totalSummaryBytes);
return false;
}
示例7:
Int32 CContentService::ObserverNode::CountUriSegments(
/* [in] */ IUri* uri)
{
if (NULL == uri) {
return 0;
}
ArrayOf<String>* pathSegments;
FAIL_RETURN(uri->GetPathSegments(&pathSegments));
return pathSegments->GetLength() + 1;
}
示例8: NativeCreate
Int64 CDashPathEffect::NativeCreate(
/* [in] */ const ArrayOf<Float>& intervalArray,
/* [in] */ Float phase)
{
int count = intervalArray.GetLength() & ~1; // even number
#ifdef SK_SCALAR_IS_FLOAT
SkScalar* intervals = intervalArray.GetPayload();
#else
#error Need to convert float array to SkScalar array before calling the following function.
#endif
SkPathEffect* effect = SkDashPathEffect::Create(intervals, count, phase);
return reinterpret_cast<Int64>(effect);
}
示例9: BindBlob
ECode SQLiteProgram::BindBlob(
/* [in] */ Int32 index,
/* [in] */ const ArrayOf<Byte>& value)
{
AutoPtr<IArrayOf> array;
CArrayOf::New(EIID_IByte, value.GetLength(), (IArrayOf**)&array);
for (Int32 i = 0; i < value.GetLength(); ++i) {
AutoPtr<IByte> bv;
CByte::New(value[i], (IByte**)&bv);
array->Set(i, bv);
}
return Bind(index, array);
}
示例10: NativeCreate
Int32 CDashPathEffect::NativeCreate(
/* [in] */ const ArrayOf<Float>& intervals,
/* [in] */ Float phase)
{
Int32 count = intervals.GetLength() & ~1; // even number
Float* values = intervals.GetPayload();
SkAutoSTMalloc<32, SkScalar> storage(count);
SkScalar* nativeIntervals = storage.get();
for (int i = 0; i < count; i++) {
nativeIntervals[i] = SkFloatToScalar(values[i]);
}
return reinterpret_cast<Int32>(new SkDashPathEffect(
nativeIntervals, count, SkFloatToScalar(phase)));
}
示例11: memcpy
void MatrixCursor::EnsureCapacity(
/* [in] */ Int32 size)
{
if (size > mData->GetLength()) {
ArrayOf< AutoPtr<IInterface> >* oldData = mData;
Int32 newSize = mData->GetLength() * 2;
if (newSize < size) {
newSize = size;
}
mData = ArrayOf< AutoPtr<IInterface> >::Alloc(newSize);
memcpy(mData->GetPayload(), oldData->GetPayload(),
oldData->GetLength() * sizeof(AutoPtr<IInterface>));
ArrayOf< AutoPtr<IInterface> >::Free(oldData);
}
}
示例12: VALIDATE_NOT_NULL
ECode SyncStateContractHelpers::NewSetOperation(
/* [in] */ IUri* uri,
/* [in] */ IAccount* account,
/* [in] */ const ArrayOf<Byte>& data,
/* [out] */ IContentProviderOperation** operation)
{
VALIDATE_NOT_NULL(operation);
AutoPtr<IContentValues> values;
FAIL_RETURN(CContentValues::New((IContentValues**)&values))
AutoPtr<IArrayOf> array;
FAIL_RETURN(CArrayOf::New(EIID_IByte, data.GetLength(), (IArrayOf**)&array))
FAIL_RETURN(values->PutBytes(ISyncStateContractColumns::DATA, array))
AutoPtr<IContentProviderOperationHelper> helper;
FAIL_RETURN(CContentProviderOperationHelper::AcquireSingleton((IContentProviderOperationHelper**)&helper))
AutoPtr<IContentProviderOperationBuilder> builder;
FAIL_RETURN(helper->NewInsert(uri, (IContentProviderOperationBuilder**)&builder))
String name, type;
FAIL_RETURN(account->GetName(&name))
FAIL_RETURN(account->GetType(&type))
AutoPtr<ICharSequence> cname, ctype;
FAIL_RETURN(CStringWrapper::New(name, (ICharSequence**)&cname))
FAIL_RETURN(CStringWrapper::New(type, (ICharSequence**)&ctype))
FAIL_RETURN(builder->WithValue(ISyncStateContractColumns::ACCOUNT_NAME, (IInterface*)cname))
FAIL_RETURN(builder->WithValue(ISyncStateContractColumns::ACCOUNT_TYPE, (IInterface*)ctype))
return builder->Build(operation);
}
示例13: testLocales
int CTest::testLocales(int argc, char* argv[]) {
// Just run through them all. Handy as a poor man's benchmark, and a sanity check.
ArrayOf<ILocale*>* arrloc;
AutoPtr<ILocaleHelper> lochelp;
CLocaleHelper::AcquireSingleton((ILocaleHelper **)&lochelp);
lochelp->GetAvailableLocales(&arrloc);
for (int i = 0; i < arrloc->GetLength(); i++) {
AutoPtr<ILocale> l = (*arrloc)[i];
AutoPtr<ISimpleDateFormat> sdf;
CSimpleDateFormat::New(String("yyyy-MM-dd HH:mm:ss zzzz"), l , (ISimpleDateFormat **)&sdf);
AutoPtr<IDate> adate;
CDate::New(0,(IDate **)&adate);
String str;
sdf->FormatDate(adate,&str);
PFL_EX("str:%s " ,str.string())
}
}
示例14: mOpenCount
XmlBlock::XmlBlock(
/* [in] */ const ArrayOf<Byte>& data)
: mOpenCount(1)
, mOpen(TRUE)
{
mNative = NativeCreate(data, 0, data.GetLength());
mStrings = new StringBlock(NativeGetStringBlock(mNative), FALSE);
}
示例15: NativeGetBlob
ECode CursorWindow::NativeGetBlob(
/* [in] */ Int32 row,
/* [in] */ Int32 column,
/* [out] */ ArrayOf<Byte>** blob)
{
ECode ec = NOERROR;
int32_t err;
NativeCursorWindow * window = mNativeWindow;
// LOG_WINDOW("Getting blob for %d,%d from %p", row, column, window);
field_slot_t field;
err = window->read_field_slot(row, column, &field);
if (err != 0) {
*blob = NULL;
// throwExceptionWithRowCol(env, row, column);
return E_ILLEGAL_STATE_EXCEPTION;
}
uint8_t type = field.type;
if (type == FIELD_TYPE_BLOB || type == FIELD_TYPE_STRING) {
ArrayOf<Byte>* byteArray = ArrayOf<Byte>::Alloc(field.data.buffer.size);
// LOG_ASSERT(byteArray, "Native could not create new byte[]");
memcpy(byteArray->GetPayload(), window->offsetToPtr(field.data.buffer.offset),
field.data.buffer.size);
*blob = byteArray;
return NOERROR;
}
else if (type == FIELD_TYPE_INTEGER) {
ec = throw_sqlite3_exception(NULL);
}
else if (type == FIELD_TYPE_FLOAT) {
ec = throw_sqlite3_exception(NULL);
}
else if (type == FIELD_TYPE_NULL) {
// do nothing
}
else {
// throwUnknowTypeException(env, type);
ec = E_ILLEGAL_STATE_EXCEPTION;
}
*blob = NULL;
return ec;
}