void ByteMapKeyCodec::read(::Ice::Int& v, const Freeze::Key& bytes, const ::Ice::CommunicatorPtr& communicator, const Ice::EncodingVersion& encoding) { IceInternal::InstancePtr instance = IceInternal::getInstance(communicator); IceInternal::BasicStream stream(instance.get(), encoding, &bytes[0], &bytes[0] + bytes.size()); stream.read(v); }
void ByteMapKeyCodec::write(::Ice::Int v, Freeze::Key& bytes, const ::Ice::CommunicatorPtr& communicator, const Ice::EncodingVersion& encoding) { IceInternal::InstancePtr instance = IceInternal::getInstance(communicator); IceInternal::BasicStream stream(instance.get(), encoding, true); stream.write(v); ::std::vector<Ice::Byte>(stream.b.begin(), stream.b.end()).swap(bytes); }
void ByteMapValueCodec::read(::Demo::ByteSeq& v, const Freeze::Value& bytes, const ::Ice::CommunicatorPtr& communicator, const Ice::EncodingVersion& encoding) { IceInternal::InstancePtr instance = IceInternal::getInstance(communicator); IceInternal::BasicStream stream(instance.get(), encoding, &bytes[0], &bytes[0] + bytes.size()); stream.startReadEncaps(); stream.read(v); stream.endReadEncaps(); }
void ByteMapValueCodec::write(const ::Demo::ByteSeq& v, Freeze::Value& bytes, const ::Ice::CommunicatorPtr& communicator, const Ice::EncodingVersion& encoding) { IceInternal::InstancePtr instance = IceInternal::getInstance(communicator); IceInternal::BasicStream stream(instance.get(), encoding, true); stream.startWriteEncaps(); stream.write(v); stream.endWriteEncaps(); ::std::vector<Ice::Byte>(stream.b.begin(), stream.b.end()).swap(bytes); }
void Freeze::ObjectStoreBase::unmarshal(Identity& ident, const Key& bytes, const CommunicatorPtr& communicator, const EncodingVersion& encoding) { IceInternal::InstancePtr instance = IceInternal::getInstance(communicator); IceInternal::BasicStream stream(instance.get(), encoding, &bytes[0], &bytes[0] + bytes.size()); stream.read(ident); }
Ice::ThreadHookPlugin::ThreadHookPlugin(const CommunicatorPtr& communicator, const ThreadNotificationPtr& threadHook) { if(communicator == 0) { throw PluginInitializationException(__FILE__, __LINE__, "Communicator cannot be null"); } IceInternal::InstancePtr instance = IceInternal::getInstance(communicator); instance->setThreadHook(threadHook); }
void Freeze::ObjectStoreBase::marshal(const Identity& ident, Key& bytes, const CommunicatorPtr& communicator, const EncodingVersion& encoding) { IceInternal::InstancePtr instance = IceInternal::getInstance(communicator); IceInternal::BasicStream stream(instance.get(), encoding, true); stream.write(ident); vector<Byte>(stream.b.begin(), stream.b.end()).swap(bytes); }
Ice::ThreadHookPlugin::ThreadHookPlugin(const CommunicatorPtr& communicator, function<void()> threadStart, function<void()> threadStop) { if(communicator == nullptr) { throw PluginInitializationException(__FILE__, __LINE__, "Communicator cannot be null"); } IceInternal::InstancePtr instance = IceInternal::getInstance(communicator); instance->setThreadHook(move(threadStart), move(threadStop)); }
Ice::LoggerPlugin::LoggerPlugin(const CommunicatorPtr& communicator, const LoggerPtr& logger) { if(communicator == 0) { throw PluginInitializationException(__FILE__, __LINE__, "Communicator cannot be null"); } if(logger == 0) { throw PluginInitializationException(__FILE__, __LINE__, "Logger cannot be null"); } IceInternal::InstancePtr instance = IceInternal::getInstance(communicator); instance->setLogger(logger); }
IceGrid::ApplicationInfo SqlStringApplicationInfoDict::find(const DatabaseConnectionPtr& connection, const string& name) { QSqlQuery query(connection->sqlConnection()); string queryString = "SELECT * FROM "; queryString += _table; queryString += " WHERE name = ?;"; query.prepare(queryString.c_str()); query.bindValue(0, name.c_str()); if(!query.exec()) { throwDatabaseException(__FILE__, __LINE__, query.lastError()); } if(query.next()) { IceGrid::ApplicationInfo info; info.uuid = query.value(1).toString().toStdString(); info.createTime = query.value(2).toLongLong(); info.createUser = query.value(3).toString().toStdString(); info.updateTime = query.value(4).toLongLong(); info.updateUser = query.value(5).toString().toStdString(); info.revision = query.value(6).toInt(); QByteArray bytes = query.value(7).toByteArray(); IceInternal::InstancePtr instance = IceInternal::getInstance(_communicator); IceInternal::BasicStream stream(instance.get()); stream.b.resize(bytes.size()); ::memcpy(&stream.b[0], bytes.data(), bytes.size()); stream.i = stream.b.begin(); stream.startReadEncaps(); info.descriptor.__read(&stream); stream.readPendingObjects(); stream.endReadEncaps(); return info; } else { throw NotFoundException(__FILE__, __LINE__); } }
void SqlStringApplicationInfoDict::getMap(const DatabaseConnectionPtr& connection, StringApplicationInfoDict& applicationMap) { QSqlQuery query(connection->sqlConnection()); string queryString = "SELECT * FROM "; queryString += _table; queryString += ";"; if(!query.exec(queryString.c_str())) { throwDatabaseException(__FILE__, __LINE__, query.lastError()); } while(query.next()) { string name = query.value(0).toString().toStdString(); IceGrid::ApplicationInfo info; info.uuid = query.value(1).toString().toStdString(); info.createTime = query.value(2).toLongLong(); info.createUser = query.value(3).toString().toStdString(); info.updateTime = query.value(4).toLongLong(); info.updateUser = query.value(5).toString().toStdString(); info.revision = query.value(6).toInt(); QByteArray bytes = query.value(7).toByteArray(); IceInternal::InstancePtr instance = IceInternal::getInstance(_communicator); IceInternal::BasicStream stream(instance.get()); stream.b.resize(bytes.size()); ::memcpy(&stream.b[0], bytes.data(), bytes.size()); stream.i = stream.b.begin(); stream.startReadEncaps(); info.descriptor.__read(&stream); stream.readPendingObjects(); stream.endReadEncaps(); applicationMap[name] = info; } }
void Freeze::ObjectStoreBase::marshal(const ObjectRecord& v, Value& bytes, const CommunicatorPtr& communicator, const EncodingVersion& encoding, bool keepStats) { IceInternal::InstancePtr instance = IceInternal::getInstance(communicator); IceInternal::BasicStream stream(instance.get(), encoding, true); stream.startWriteEncaps(); if(keepStats) { stream.write(v); } else { stream.write(v.servant); } stream.writePendingObjects(); stream.endWriteEncaps(); vector<Byte>(stream.b.begin(), stream.b.end()).swap(bytes); }
void Freeze::ObjectStoreBase::unmarshal(ObjectRecord& v, const Value& bytes, const CommunicatorPtr& communicator, const EncodingVersion& encoding, bool keepStats) { IceInternal::InstancePtr instance = IceInternal::getInstance(communicator); IceInternal::BasicStream stream(instance.get(), encoding, &bytes[0], &bytes[0] + bytes.size()); stream.sliceObjects(false); stream.startReadEncaps(); if(keepStats) { stream.read(v); } else { stream.read(v.servant); } stream.readPendingObjects(); stream.endReadEncaps(); }
AsyncResult::AsyncResult(const CommunicatorPtr& communicator, const IceInternal::InstancePtr& instance, const string& op, const CallbackBasePtr& del, const LocalObjectPtr& cookie) : _instance(instance), _sentSynchronously(false), _is(instance.get(), Ice::currentProtocolEncoding), _communicator(communicator), _operation(op), _callback(del), _cookie(cookie), _state(0) { if(!_callback) { throw IceUtil::IllegalArgumentException(__FILE__, __LINE__); } const_cast<CallbackBasePtr&>(_callback) = _callback->verify(_cookie); }
void SqlStringApplicationInfoDict::put(const DatabaseConnectionPtr& connection, const string& name, const ApplicationInfo& info) { IceInternal::InstancePtr instance = IceInternal::getInstance(_communicator); IceInternal::BasicStream stream(instance.get()); stream.startWriteEncaps(); info.descriptor.__write(&stream); stream.writePendingObjects(); stream.endWriteEncaps(); QSqlQuery query(connection->sqlConnection()); ostringstream queryString; queryString << "UPDATE " << _table << " SET uuid = ?, createTime = '" << info.createTime << "', createUser = ?, updateTime = '" << info.updateTime << "', updateUser = ?, revision = '" << info.revision << "', descriptor = "; QString driver = connection->sqlConnection().driverName(); if(driver == "QPSQL" || driver == "QODBC") { vector<Ice::Byte> bytes(stream.b.size()); ::memcpy(&bytes[0], stream.b.begin(), stream.b.size()); if(driver == "QPSQL") { queryString << "E'" << escapePsqlBinary(bytes) << "'"; } else { queryString << "0x" << escapeOdbcBinary(bytes); } } else { queryString << "?"; } queryString << " WHERE name = ?;"; query.prepare(queryString.str().c_str()); int placeholder = 0; query.bindValue(placeholder++, info.uuid.c_str()); query.bindValue(placeholder++, info.createUser.c_str()); query.bindValue(placeholder++, info.updateUser.c_str()); if(driver != "QPSQL" && driver != "QODBC") { QByteArray bytes; bytes.resize(static_cast<int>(stream.b.size())); ::memcpy(bytes.data(), stream.b.begin(), stream.b.size()); QVariant descriptor(bytes); query.bindValue(placeholder++, descriptor); } query.bindValue(placeholder, name.c_str()); if(!query.exec()) { throwDatabaseException(__FILE__, __LINE__, query.lastError()); } if(query.numRowsAffected() == 0) { // // We do a find since some databases (MySQL) return 0 for number of rows affected // if row exists but data was not changed from previous values. // try { find(connection, name); } catch(const NotFoundException&) { QSqlQuery insertQuery(connection->sqlConnection()); queryString.str(""); queryString << "INSERT INTO " << _table << " VALUES(?, ?, '" << info.createTime << "', ?, '" << info.updateTime << "', ?, '" << info.revision << "', "; if(driver == "QPSQL" || driver == "QODBC") { vector<Ice::Byte> bytes(stream.b.size()); ::memcpy(&bytes[0], stream.b.begin(), stream.b.size()); if(driver == "QPSQL") { queryString << "E'" << escapePsqlBinary(bytes) << "'"; } else { queryString << "0x" << escapeOdbcBinary(bytes); } } else { queryString << "?"; } queryString << ");"; insertQuery.prepare(queryString.str().c_str()); insertQuery.bindValue(0, name.c_str()); insertQuery.bindValue(1, info.uuid.c_str()); insertQuery.bindValue(2, info.createUser.c_str()); insertQuery.bindValue(3, info.updateUser.c_str()); if(driver != "QPSQL" && driver != "QODBC") { QByteArray bytes; bytes.resize(static_cast<int>(stream.b.size())); ::memcpy(bytes.data(), stream.b.begin(), stream.b.size()); QVariant descriptor(bytes); insertQuery.bindValue(4, descriptor); } if(!insertQuery.exec()) { throwDatabaseException(__FILE__, __LINE__, insertQuery.lastError()); } } } }