本文整理汇总了C++中AutoPtr::Add方法的典型用法代码示例。如果您正苦于以下问题:C++ AutoPtr::Add方法的具体用法?C++ AutoPtr::Add怎么用?C++ AutoPtr::Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AutoPtr
的用法示例。
在下文中一共展示了AutoPtr::Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: StartTruncatedScan
ECode BluetoothLeScanner::StartTruncatedScan(
/* [in] */ IList* truncatedFilters,
/* [in] */ IScanSettings* settings,
/* [in] */ IScanCallback* callback)
{
Int32 filterSize;
truncatedFilters->GetSize(&filterSize);
//List<ScanFilter> scanFilters = new ArrayList<ScanFilter>(filterSize);
AutoPtr<IList> scanFilters;
CArrayList::New((IList**)&scanFilters);
//List<List<ResultStorageDescriptor>> scanStorages =
// new ArrayList<List<ResultStorageDescriptor>>(filterSize);
AutoPtr<IList> scanStorages;
CArrayList::New((IList**)&scanStorages);
//for (TruncatedFilter filter : truncatedFilters) {
Int32 size;
truncatedFilters->GetSize(&size);
for (Int32 i = 0; i < size; ++i) {
AutoPtr<IInterface> obj;
truncatedFilters->Get(i, (IInterface**)&obj);
ITruncatedFilter* filter = ITruncatedFilter::Probe(obj);
AutoPtr<IScanFilter> scanFilter;
filter->GetFilter((IScanFilter**)&scanFilter);
scanFilters->Add(TO_IINTERFACE(scanFilters));
AutoPtr<IList> list;
filter->GetStorageDescriptors((IList**)&list);
scanStorages->Add(TO_IINTERFACE(list));
}
StartScan(scanFilters, settings, callback, scanStorages);
return NOERROR;
}
示例2: PEL
int CTest::test_trimToSize_02(int argc, char* argv[])
{
PEL("CTest::test_trimToSize_02")
// ArrayList list = new ArrayList(Arrays.asList(new String[] { "a", "b", "c",
// "d", "e", "f", "g" }));
Boolean isflag = FALSE;
AutoPtr<IArrayList> list;
CArrayList::New((IArrayList**)&list);
AutoPtr<ICharSequence> csa;
CString::New(String("a"), (ICharSequence**)&csa);
AutoPtr<ICharSequence> csb;
CString::New(String("b"), (ICharSequence**)&csb);
AutoPtr<ICharSequence> csc;
CString::New(String("c"), (ICharSequence**)&csc);
AutoPtr<ICharSequence> csd;
CString::New(String("d"), (ICharSequence**)&csd);
AutoPtr<ICharSequence> cse;
CString::New(String("e"), (ICharSequence**)&cse);
AutoPtr<ICharSequence> csf;
CString::New(String("f"), (ICharSequence**)&csf);
AutoPtr<ICharSequence> csg;
CString::New(String("g"), (ICharSequence**)&csg);
list->Add(csa, &isflag);
list->Add(csb, &isflag);
list->Add(csc, &isflag);
list->Add(csd, &isflag);
list->Add(cse, &isflag);
list->Add(csf, &isflag);
list->Add(csg, &isflag);
list->Remove(csa, &isflag);
list->Remove(csf, &isflag);
list->TrimToSize();
return 0;
}
示例3: test_removeLjava_lang_Object
int CTest::test_removeLjava_lang_Object(int argc, char* argv[])
{
PEL("CTest::test_removeLjava_lang_Object")
// List list = new ArrayList(Arrays.asList(new String[] { "a", "b", "c",
// "d", "e", "f", "g" }));
Boolean isflag = FALSE;
AutoPtr<IArrayList> list;
CArrayList::New((IArrayList**)&list);
AutoPtr<ICharSequence> csa;
CString::New(String("a"), (ICharSequence**)&csa);
AutoPtr<ICharSequence> csb;
CString::New(String("b"), (ICharSequence**)&csb);
AutoPtr<ICharSequence> csc;
CString::New(String("c"), (ICharSequence**)&csc);
AutoPtr<ICharSequence> csd;
CString::New(String("d"), (ICharSequence**)&csd);
AutoPtr<ICharSequence> cse;
CString::New(String("e"), (ICharSequence**)&cse);
AutoPtr<ICharSequence> csf;
CString::New(String("f"), (ICharSequence**)&csf);
AutoPtr<ICharSequence> csg;
CString::New(String("g"), (ICharSequence**)&csg);
list->Add(csa, &isflag);
list->Add(csb, &isflag);
list->Add(csc, &isflag);
list->Add(csd, &isflag);
list->Add(cse, &isflag);
list->Add(csf, &isflag);
list->Add(csg, &isflag);
assert((list->Remove(csa, &isflag), isflag));
assert((list->Remove(csf, &isflag), isflag));
// String[] result = new String[5];
AutoPtr< ArrayOf<IInterface*> > result = ArrayOf<IInterface*>::Alloc(5);
AutoPtr< ArrayOf<IInterface*> > outarr;
list->ToArrayEx(result, (ArrayOf<IInterface*>**)&outarr);
String str[5] = {String("b"), String("c"), String("d"), String("e"), String("g") };
for (int i = 0; i < 5; ++i) {
AutoPtr<ICharSequence> res = (ICharSequence*) (*outarr)[i]->Probe(EIID_ICharSequence);
if (res == NULL) {
assert(0);
}
String outstr;
res->ToString(&outstr);
assert( outstr == str[i]);
}
// assertTrue("Removed wrong element 3", Arrays.equals(result, new String[] { "b", "c", "d", "e", "g" }));
return 0;
}
示例4: UpdateListView
ECode CActivityOne::UpdateListView()
{
Slogger::D(TAG, "Update Wifi Displays, count: %d", mWifiDisplays ? mWifiDisplays->GetLength() : 0);
if (mWifiDisplays == NULL || mWifiDisplays->GetLength() == 0) {
mDisplayListView->SetAdapter(NULL);
return NOERROR;
}
AutoPtr<IObjectContainer> dataList;
CParcelableObjectContainer::New((IObjectContainer**)&dataList);
String address, name;
IWifiDisplay* display;
for (Int32 i = 0; i < mWifiDisplays->GetLength(); ++i) {
display = (*mWifiDisplays)[i];
display->GetDeviceAddress(&address);
display->GetDeviceName(&name);
StringBuilder sb(name);
sb += "=";
sb += address;
AutoPtr<ICharSequence> seq = sb.ToCharSequence();
dataList->Add(seq->Probe(EIID_IInterface));
}
AutoPtr<IArrayAdapter> adapter;
CArrayAdapter::New(this, R::layout::list_item, dataList, (IArrayAdapter**)&adapter);
assert(adapter != NULL);
mDisplayListView->SetAdapter(adapter.Get());
return NOERROR;
}
示例5: while
AutoPtr<IEnumeration> CNamespaceSupport::Context::GetPrefixes ()
{
if (mPrefixTable.IsEmpty()) {
if (EMPTY_ENUMERATION == NULL) {
EMPTY_ENUMERATION = InitEMPTY_ENUMERATION();
}
return EMPTY_ENUMERATION;
}
else {
AutoPtr<IArrayList> prefixes;
CArrayList::New((IArrayList**)&prefixes);
HashMap<String, String>::Iterator iter = mPrefixTable.Begin();
while (iter != mPrefixTable.End()) {
AutoPtr<ICharSequence> csq;
CString::New(iter->mFirst, (ICharSequence**)&csq);
prefixes->Add(csq);
iter++;
}
AutoPtr<IEnumeration> enu;
Collections::Enumeration(ICollection::Probe(prefixes), (IEnumeration**)&enu);
return enu;
}
}
示例6: GetPrefixes
ECode CNamespaceSupport::GetPrefixes(
/* [in] */ const String& uri,
/* [out] */ IEnumeration** result)
{
VALIDATE_NOT_NULL(result)
AutoPtr<IArrayList> prefixes;
CArrayList::New((IArrayList**)&prefixes);
AutoPtr<IEnumeration> allPrefixes;
GetPrefixes((IEnumeration**)&allPrefixes);
Boolean hasMore;
while (allPrefixes->HasMoreElements(&hasMore), hasMore) {
AutoPtr<IInterface> obj;
allPrefixes->GetNextElement((IInterface**)&obj);
ICharSequence* seq = ICharSequence::Probe(obj);
String prefix, us;
seq->ToString(&prefix);
GetURI(prefix, &us);
if (uri.Equals(us)) {
AutoPtr<ICharSequence> csq;
CString::New(prefix, (ICharSequence**)&csq);
prefixes->Add(csq);
}
}
*result = IEnumeration::Probe(prefixes);
REFCOUNT_ADD(*result)
return NOERROR;
}
示例7: String
AutoPtr<ArrayOf<IEncodedStringValue*> > EncodedStringValue::Extract(
/* [in] */ const String& src)
{
AutoPtr<ArrayOf<String> > values;
StringUtils::Split(src, String(";"), (ArrayOf<String>**)&values);
AutoPtr<IArrayList> list;
CArrayList::New((IArrayList**)&list);
for (Int32 i = 0; i < values->GetLength(); i++) {
if ((*values)[i].GetLength() > 0) {
AutoPtr<IEncodedStringValue> p;
CEncodedStringValue::New((*values)[i], (IEncodedStringValue**)&p);
list->Add(p);
}
}
Int32 len = 0;
list->GetSize(&len);
if (len > 0) {
AutoPtr<ArrayOf<IEncodedStringValue*> > arr = ArrayOf<IEncodedStringValue*>::Alloc(len);
AutoPtr<ArrayOf<IInterface*> > res;
list->ToArray((ArrayOf<IInterface*>*)arr.Get(), (ArrayOf<IInterface*>**)&res);
return (ArrayOf<IEncodedStringValue*>*)res.Get();
}
else {
return NULL;
}
}
示例8: GetAllServices
ECode RegisteredServicesCache::GetAllServices(
/* [in] */ Int32 userId,
/* [out] */ IList** list)
{
VALIDATE_NOT_NULL(list)
AutoLock lock(mServicesLock);
// Find user and lazily populate cache
AutoPtr<UserServices> user = FindOrCreateUserLocked(userId);
if (user->mServices == NULL) {
GenerateServicesMap(userId);
}
AutoPtr<IArrayList> infos;
CArrayList::New((IArrayList**)&infos);
HashMap<AutoPtr<IInterface>, AutoPtr<IRegisteredServicesCacheServiceInfo> >::Iterator itr = user->mServices->Begin();
for (; itr != user->mServices->End(); ++itr) {
infos->Add(TO_IINTERFACE(itr->mSecond));
}
*list = IList::Probe(infos);
REFCOUNT_ADD(*list)
return NOERROR;
}
示例9: GetAllAddresses
ECode LinkProperties::GetAllAddresses(
/* [out] */ IList** result)
{
VALIDATE_NOT_NULL(result)
AutoPtr<IList> addresses;
CArrayList::New((IList**)&addresses);
AutoPtr<IIterator> it;
mLinkAddresses->GetIterator((IIterator**)&it);
Boolean hasNext;
while (it->HasNext(&hasNext), hasNext) {
AutoPtr<IInterface> obj;
it->GetNext((IInterface**)&obj);
AutoPtr<IInetAddress> address;
ILinkAddress::Probe(obj)->GetAddress((IInetAddress**)&address);
addresses->Add(address);
}
AutoPtr<ICollection> links;
mStackedLinks->GetValues((ICollection**)&links);
it = NULL;
links->GetIterator((IIterator**)&it);
while (it->HasNext(&hasNext), hasNext) {
AutoPtr<IInterface> obj;
it->GetNext((IInterface**)&obj);
AutoPtr<IList> allAddresses;
ILinkProperties::Probe(obj)->GetAllAddresses((IList**)&allAddresses);
addresses->AddAll(ICollection::Probe(allAddresses));
}
*result = addresses;
REFCOUNT_ADD(*result)
return NOERROR;
}
示例10: DispatchPopulateAccessibilityEvent
ECode CAccessibleDateAnimator::DispatchPopulateAccessibilityEvent(
/* [in] */ IAccessibilityEvent* event,
/* [out] */ Boolean* result)
{
VALIDATE_NOT_NULL(result);
Int32 type = 0;
event->GetEventType(&type);
if (type == IAccessibilityEvent::TYPE_WINDOW_STATE_CHANGED) {
// Clear the event's current text so that only the current date will be spoken.
AutoPtr<IList> list;
IAccessibilityRecord::Probe(event)->GetText((IList**)&list);
list->Clear();
Int32 flags = IDateUtils::FORMAT_SHOW_DATE | IDateUtils::FORMAT_SHOW_YEAR |
IDateUtils::FORMAT_SHOW_WEEKDAY;
AutoPtr<IContext> context;
GetContext((IContext**)&context);
String dateString = DateUtils::FormatDateTime(context, mDateMillis, flags);
AutoPtr<ICharSequence> seq;
CString::New(dateString, (ICharSequence**)&seq);
list->Add(seq);
*result = TRUE;
return NOERROR;
}
return ViewAnimator::DispatchPopulateAccessibilityEvent(event, result);
}
示例11: OnCreate
ECode CActivityOne::OnCreate(
/* [in] */ IBundle* savedInstanceState)
{
Activity::OnCreate(savedInstanceState);
PRINT_ENTER_LEAVE("CActivityOne::OnCreate");
SetContentView(R::layout::main);
AutoPtr<IObjectContainer> dataList;
CParcelableObjectContainer::New((IObjectContainer**)&dataList);
for (Int32 i = 0; i < 2; ++i) {
StringBuilder sb("测试 ");
sb += i;
AutoPtr<ICharSequence> seq = sb.ToCharSequence();
dataList->Add(seq.Get());
}
AutoPtr<IArrayAdapter> adapter;
CArrayAdapter::New(this, R::layout::list_item, dataList, (IArrayAdapter**)&adapter);
assert(adapter != NULL);
AutoPtr<IView> temp = FindViewById(R::id::autoCompleteTextView1);
mView = IAutoCompleteTextView::Probe(temp);
AutoPtr<IListAdapter> tempAdapter = IListAdapter::Probe(adapter.Get());
mView->SetAdapter(tempAdapter);
AutoPtr<IViewOnFocusChangeListener> li = new FocusChange(this);
//mView->SetOnFocusChangeListener(li);
return NOERROR;
}
示例12:
ECode OpenSSLX509Certificate::FromPkcs7PemInputStream(
/* [in] */ IInputStream* is,
/* [out] */ IList** result)
{
VALIDATE_NOT_NULL(result)
AutoPtr<IOpenSSLBIOInputStream> bis;
COpenSSLBIOInputStream::New(is, (IOpenSSLBIOInputStream**)&bis);
AutoPtr<ArrayOf<Int64> > certRefs;
// try {
Int64 context = 0;
bis->GetBioContext(&context);
NativeCrypto::PEM_read_bio_PKCS7(context,
INativeCrypto::PKCS7_CERTS, (ArrayOf<Int64>**)&certRefs);
// } catch (Exception e) {
// throw new ParsingException(e);
// } finally {
bis->Release();
// }
AutoPtr<IList> certs;
CArrayList::New(
certRefs->GetLength(), (IList**)&certs);
for (Int32 i = 0; i < certRefs->GetLength(); i++) {
if ((*certRefs)[i] == 0) {
continue;
}
AutoPtr<IOpenSSLX509Certificate> p;
COpenSSLX509Certificate::New((*certRefs)[i], (IOpenSSLX509Certificate**)&p);
certs->Add(p);
}
*result = certs;
REFCOUNT_ADD(*result)
return NOERROR;
}
示例13: while
int CTest::testIPv6(int argc, char* argv[])
{
AutoPtr<INetworkInterfaceHelper> help;
CNetworkInterfaceHelper::AcquireSingleton((INetworkInterfaceHelper**)&help);
AutoPtr<INetworkInterface> lo;
help->GetByName(String("lo"), (INetworkInterface**)&lo);
AutoPtr<IEnumeration> enu;
lo->GetInetAddresses((IEnumeration**)&enu);
AutoPtr<IArrayList> al;
CArrayList::New((IArrayList**)&al);
Boolean hasNext;
while (enu->HasMoreElements(&hasNext), hasNext) {
AutoPtr<IInterface> p;
enu->NextElement((IInterface**)&p);
Boolean b;
al->Add(p, &b);
}
AutoPtr<ISet> actual;
CHashSet::New((ICollection*)al, (ISet**)&actual);
AutoPtr<ISet> expected;
CHashSet::New((ISet**)&expected);
Boolean b = FALSE;
AutoPtr<IInet4AddressHelper> net4Hlp;
CInet4AddressHelper::AcquireSingleton((IInet4AddressHelper**)&net4Hlp);
AutoPtr<IInetAddress> loopback;
net4Hlp->GetLOOPBACK((IInetAddress**)&loopback);
expected->Add(loopback, &b);
AutoPtr<IInet6AddressHelper> net6Hlp;
CInet6AddressHelper::AcquireSingleton((IInet6AddressHelper**)&net6Hlp);
AutoPtr<ArrayOf<Byte> > arr = ArrayOf<Byte>::Alloc(16);
for (int i = 0; i < 15; ++i)
{
arr->Set(i, 0);
}
arr->Set(15, 1);
AutoPtr<IInet6Address> addr;
net6Hlp->GetByAddressEx(String("localhost"), arr, NULL, (IInet6Address**)&addr);
expected->Add(addr, &b);
expected->Equals(actual, &b);
assert(b);
return 0;
}
示例14: while
AutoPtr< ArrayOf<String> > AbstractVerifier::GetDNSSubjectAlts(
/* [in] */ IX509Certificate* cert)
{
AutoPtr<ILinkedList> subjectAltList;
CLinkedList::New((ILinkedList**)&subjectAltList);
AutoPtr<ICollection> subjectAltCol = ICollection::Probe(subjectAltList);
AutoPtr<ICollection> c;
// try {
if (FAILED(cert->GetSubjectAlternativeNames((ICollection**)&c))) {
Logger::E("AbstractVerifier", "Error parsing certificate.");
}
// }
// catch(CertificateParsingException cpe) {
// Logger.getLogger(AbstractVerifier.class.getName())
// .log(Level.FINE, "Error parsing certificate.", cpe);
// }
if(c != NULL) {
AutoPtr<IIterable> iterable = IIterable::Probe(c);
AutoPtr<IIterator> it;
iterable->GetIterator((IIterator**)&it);
Boolean hasNext;
while (it->HasNext(&hasNext), hasNext) {
AutoPtr<IList> aC;
it->GetNext((IInterface**)&aC);
AutoPtr<IInteger32> value;
aC->Get(0, (IInterface**)&value);
Int32 type;
value->GetValue(&type);
// If type is 2, then we've got a dNSName
if (type == 2) {
AutoPtr<ICharSequence> cs;
aC->Get(1, (IInterface**)&cs);
subjectAltCol->Add(cs);
}
}
}
Boolean isEmpty;
if(subjectAltList->IsEmpty(&isEmpty), !isEmpty) {
Int32 size;
subjectAltCol->GetSize(&size);
AutoPtr< ArrayOf<String> > subjectAlts = ArrayOf<String>::Alloc(size);
AutoPtr< ArrayOf<IInterface*> > array;
subjectAltCol->ToArray((ArrayOf<IInterface*>**)&array);
for (Int32 i = 0; i < array->GetLength(); ++i) {
AutoPtr<ICharSequence> cs = ICharSequence::Probe((*array)[i]);
String str;
cs->ToString(&str);
(*subjectAlts)[i] = str;
}
return subjectAlts;
}
else {
return NULL;
}
}
示例15:
AutoPtr<IObjectContainer> ActivityChooserModel::TransfromList(
/* [in] */ List<AutoPtr<T> >& list)
{
AutoPtr<IObjectContainer> container;
CObjectContainer::New((IObjectContainer**)&container);
typename List<AutoPtr<T> >::Iterator it = list.Begin();
for(; it != list.End(); it++)
{
container->Add(*it);
}
return container;
}