void ArrayIter::begin(CVarRef map, CStrRef context) { try { new (this) ArrayIter(map.begin(context)); } catch (...) { m_data = NULL; throw; } }
ProcessSharedVariant::ProcessSharedVariant(CVarRef source, ProcessSharedVariantLock* lock) : m_lock(putPtr(lock)) { switch (source.getType()) { case KindOfBoolean: { m_type = KindOfBoolean; m_data.num = source.toBoolean(); break; } case KindOfByte: case KindOfInt16: case KindOfInt32: case KindOfInt64: { m_type = KindOfInt64; m_data.num = source.toInt64(); break; } case KindOfDouble: { m_type = KindOfDouble; m_data.dbl = source.toDouble(); break; } case LiteralString: case KindOfStaticString: case KindOfString: { String s = source.toString(); m_type = KindOfString; if (lock) { m_data.str = putPtr(SharedMemoryManager::GetSegment() ->construct<SharedMemoryString> (boost::interprocess::anonymous_instance) (s.data(), s.size())); } else { // Just need this string to live long enough for the key lookup so // don't store in shared memory. m_data.str = putPtr(new SharedMemoryString(s.data(), s.size())); } break; } case KindOfArray: { ASSERT(lock); m_type = KindOfArray; uint i = 0; ProcessSharedVariantMapData* mapData = SharedMemoryManager::GetSegment() ->construct<ProcessSharedVariantMapData> (boost::interprocess::anonymous_instance)(); m_data.map = putPtr(mapData); ProcessSharedVariantToIntMap* map = SharedMemoryManager::GetSegment() ->construct<ProcessSharedVariantToIntMap> (boost::interprocess::anonymous_instance)(); mapData->map = putPtr(map); SharedMemoryVector<SharedVariant*>* keys = SharedMemoryManager::GetSegment() ->construct<SharedMemoryVector<SharedVariant*> > (boost::interprocess::anonymous_instance)(); mapData->keys = putPtr(keys); SharedMemoryVector<SharedVariant*>* vals = SharedMemoryManager::GetSegment() ->construct<SharedMemoryVector<SharedVariant*> > (boost::interprocess::anonymous_instance)(); mapData->vals = putPtr(vals); for (ArrayIterPtr it = source.begin(); !it->end(); it->next()) { ProcessSharedVariant* key = SharedMemoryManager::GetSegment() ->construct<ProcessSharedVariant> (boost::interprocess::anonymous_instance) (it->first(), getLock()); ProcessSharedVariant* val = SharedMemoryManager::GetSegment() ->construct<ProcessSharedVariant> (boost::interprocess::anonymous_instance) (it->second(), getLock()); (*map)[key] = i++; keys->push_back(putPtr(key)); vals->push_back(putPtr(val)); } break; } default: { m_type = KindOfObject; String s = f_serialize(source); m_data.str = putPtr(SharedMemoryManager::GetSegment() ->construct<SharedMemoryString> (boost::interprocess::anonymous_instance) (s.data(), s.size())); break; } } }