25#include "Attachment.h" 
   30using namespace fbcpp::impl;
 
   39    StatusWrapper statusWrapper{client, status.get()};
 
   41    auto dpbBuilder = fbUnique(master->getUtilInterface()->getXpbBuilder(&statusWrapper, fb::IXpbBuilder::DPB,
 
   42        reinterpret_cast<const std::uint8_t*
>(options.
getDpb().data()),
 
   43        static_cast<unsigned>(options.
getDpb().size())));
 
   46        dpbBuilder->insertString(&statusWrapper, isc_dpb_lc_ctype, connectionCharSet->c_str());
 
   49        dpbBuilder->insertString(&statusWrapper, isc_dpb_user_name, userName->c_str());
 
   52        dpbBuilder->insertString(&statusWrapper, isc_dpb_password, password->c_str());
 
   54    if (
const auto role = options.
getRole())
 
   55        dpbBuilder->insertString(&statusWrapper, isc_dpb_sql_role_name, role->c_str());
 
   57    auto dispatcher = fbRef(master->getDispatcher());
 
   58    const auto dpbBuffer = dpbBuilder->getBuffer(&statusWrapper);
 
   59    const auto dpbBufferLen = dpbBuilder->getBufferLength(&statusWrapper);
 
   62        handle.reset(dispatcher->createDatabase(&statusWrapper, uri.c_str(), dpbBufferLen, dpbBuffer));
 
   64        handle.reset(dispatcher->attachDatabase(&statusWrapper, uri.c_str(), dpbBufferLen, dpbBuffer));
 
 
   67void Attachment::disconnectOrDrop(
bool drop)
 
   72    StatusWrapper statusWrapper{client, status.get()};
 
   75        handle->dropDatabase(&statusWrapper);
 
   77        handle->detach(&statusWrapper);
 
   85    disconnectOrDrop(
false);
 
 
   90    disconnectOrDrop(
true);
 
 
Represents options used when creating an Attachment object.
const std::optional< std::string > & getPassword() const
Returns the password which will be used to connect to the database.
const std::optional< std::string > & getRole() const
Returns the role which will be used to connect to the database.
const std::vector< std::uint8_t > & getDpb() const
Returns the DPB (Database Parameter Block) which will be used to connect to the database.
const std::optional< std::string > & getUserName() const
Returns the user name which will be used to connect to the database.
bool getCreateDatabase() const
Returns whether the database should be created instead of connected to.
const std::optional< std::string > & getConnectionCharSet() const
Returns the character set which will be used for the connection.
Attachment(Client &client, const std::string &uri, const AttachmentOptions &options={})
Constructs an Attachment object that connects to (or creates) the database specified by the URI using...
void disconnect()
Disconnects from the database.
bool isValid() noexcept
Returns whether the Attachment object is valid.
void dropDatabase()
Drops the database.
Represents a Firebird client library instance.
FbUniquePtr< fb::IStatus > newStatus()
Creates and returns a Firebird IStatus instance.
fb::IMaster * getMaster() noexcept
Returns the Firebird IMaster interface.