⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qlibrary.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 3 页
字号:
#else    return pluginState == MightBeAPlugin;#endif}/*!    Loads the library and returns true if the library was loaded    successfully; otherwise returns false. Since resolve() always    calls this function before resolving any symbols it is not    necessary to call it explicitly. In some situations you might want    the library loaded in advance, in which case you would use this    function.    \sa unload()*/bool QLibrary::load(){    if (!d)        return false;    if (did_load)        return d->pHnd;    did_load = true;    return d->load();}/*!    Unloads the library and returns true if the library could be    unloaded; otherwise returns false.    This happens automatically on application termination, so you    shouldn't normally need to call this function.    If other instances of QLibrary are using the same library, the    call will fail, and unloading will only happen when every instance    has called unload().    Note that on Mac OS X 10.3 (Panther), dynamic libraries cannot be unloaded.    \sa resolve(), load()*/bool QLibrary::unload(){    if (did_load) {        did_load = false;        return d->unload();    }    return false;}/*!    Returns true if the library is loaded; otherwise returns false.    \sa load() */bool QLibrary::isLoaded() const{    return d && d->pHnd;}/*!    Constructs a library with the given \a parent. */QLibrary::QLibrary(QObject *parent)    :QObject(parent), d(0), did_load(false){}/*!    Constructs a library object with the given \a parent that will    load the library specified by \a fileName.    We recommend omitting the file's suffix in \a fileName, since    QLibrary will automatically look for the file with the appropriate    suffix in accordance with the platform, e.g. ".so" on Unix,    ".dylib" on Mac OS X, and ".dll" on Windows. (See \l{fileName}.) */QLibrary::QLibrary(const QString& fileName, QObject *parent)    :QObject(parent), d(0), did_load(false){    setFileName(fileName);}/*!    Constructs a library object with the given \a parent that will    load the library specified by \a fileName and major version number \a verNum.    Currently, the version number is ignored on Windows.    We recommend omitting the file's suffix in \a fileName, since    QLibrary will automatically look for the file with the appropriate    suffix in accordance with the platform, e.g. ".so" on Unix,    ".dylib" on Mac OS X, and ".dll" on Windows. (See \l{fileName}.) */QLibrary::QLibrary(const QString& fileName, int verNum, QObject *parent)    :QObject(parent), d(0), did_load(false){    setFileNameAndVersion(fileName, verNum);}/*!    Destroys the QLibrary object.    Unless unload() was called explicitly, the library stays in memory    until the application terminates.    \sa isLoaded(), unload()*/QLibrary::~QLibrary(){    if (d)        d->release();}/*!    \property QLibrary::fileName    \brief the file name of the library    We recommend omitting the file's suffix in the file name, since    QLibrary will automatically look for the file with the appropriate    suffix (see isLibrary()).    When loading the library, QLibrary searches in all system-specific    library locations (e.g. \c LD_LIBRARY_PATH on Unix), unless the    file name has an absolute path. After loading the library    successfully, fileName() returns the fully-qualified file name of    the library, including the full path to the library if one was given    in the constructor or passed to setFileName().    For example, after successfully loading the "GL" library on Unix    platforms, fileName() will return "libGL.so". If the file name was    originally passed as "/usr/lib/libGL", fileName() will return    "/usr/lib/libGL.so".*/void QLibrary::setFileName(const QString &fileName){    if (d) {        d->release();        d = 0;        did_load = false;    }    d = QLibraryPrivate::findOrCreate(fileName);}QString QLibrary::fileName() const{    if (d)        return d->qualifiedFileName.isEmpty() ? d->fileName : d->qualifiedFileName;    return QString();}/*!    \fn void QLibrary::setFileNameAndVersion(const QString &fileName, int versionNumber)    Sets the fileName property and major version number to \a fileName    and \a versionNumber respectively.    The \a versionNumber is ignored on Windows.    \sa setFileName()*/void QLibrary::setFileNameAndVersion(const QString &fileName, int verNum){    if (d) {        d->release();        d = 0;        did_load = false;    }    d = QLibraryPrivate::findOrCreate(fileName, verNum);}/*!    Returns the address of the exported symbol \a symbol. The library is    loaded if necessary. The function returns 0 if the symbol could    not be resolved or if the library could not be loaded.    Example:    \code        typedef int (*AvgFunction)(int, int);        AvgFunction avg = (AvgFunction) library->resolve("avg");        if (avg)            return avg(5, 8);        else            return -1;    \endcode    The symbol must be exported as a C function from the library. This    means that the function must be wrapped in an \c{extern "C"} if    the library is compiled with a C++ compiler. On Windows you must    also explicitly export the function from the DLL using the    \c{__declspec(dllexport)} compiler directive, for example:    \code        extern "C" MY_EXPORT int avg(int a, int b)        {            return (a + b) / 2;        }    \endcode    with \c MY_EXPORT defined as    \code        #ifdef Q_WS_WIN        #define MY_EXPORT __declspec(dllexport)        #else        #define MY_EXPORT        #endif    \endcode*/void *QLibrary::resolve(const char *symbol){    if (!load())        return 0;    return d->resolve(symbol);}/*!    \overload    Loads the library \a fileName and returns the address of the    exported symbol \a symbol. Note that \a fileName should not    include the platform-specific file suffix; (see \l{fileName}). The    library remains loaded until the application exits.    The function returns 0 if the symbol could not be resolved or if    the library could not be loaded.    \sa resolve()*/void *QLibrary::resolve(const QString &fileName, const char *symbol){    QLibrary library(fileName);    return library.resolve(symbol);}/*!    \overload    Loads the library \a fileName with major version number \a verNum and    returns the address of the exported symbol \a symbol.    Note that \a fileName should not include the platform-specific file suffix;    (see \l{fileName}). The library remains loaded until the application exits.    \a verNum is ignored on Windows.    The function returns 0 if the symbol could not be resolved or if    the library could not be loaded.    \sa resolve()*/void *QLibrary::resolve(const QString &fileName, int verNum, const char *symbol){    QLibrary library(fileName, verNum);    return library.resolve(symbol);}/*!    \fn QString QLibrary::library() const    Use fileName() instead.*//*!    \fn void QLibrary::setAutoUnload( bool b )    Use load(), isLoaded(), and unload() as necessary instead.*//*!    \since 4.2    Returns a text string with the description of the last error that occurred.    Currently, errorString will only be set if load(), unload() or resolve() for some reason fails.*/QString QLibrary::errorString() const{    return (!d || d->errorString.isEmpty()) ? tr("Unknown error") : d->errorString;}/*!    \property QLibrary::loadHints    \brief Give the load() function some hints on how it should behave.    You can give some hints on how the symbols are resolved. Usually,    the symbols are not resolved at load time, but resolved lazily,    (that is, when resolve() is called). If you set the loadHint to    ResolveAllSymbolsHint, then all symbols will be resolved at load time    if the platform supports it.    Setting ExportExternalSymbolsHint will make the external symbols in the    library available for resolution in subsequent loaded libraries.    If LoadArchiveMemberHint is set, the file name    is composed of two components: A path which is a reference to an    archive file followed by the second component which is the reference to    the archive member. For instance, the fileName \c libGL.a(shr_64.o) will refer    to the library \c shr_64.o in the archive file named \c libGL.a. This    is only supported on the AIX platform.    The interpretation of the load hints is platform dependent, and if    you use it you are probably making some assumptions on which platform    you are compiling for, so use them only if you understand the consequences    of them.    By default, none of these flags are set, so libraries will be loaded with    lazy symbol resolution, and will not export external symbols for resolution    in other dynamically-loaded libraries.*/void QLibrary::setLoadHints(LoadHints hints){    d->loadHints = hints;}QLibrary::LoadHints QLibrary::loadHints() const{    return d->loadHints;}/* Internal, for debugging */bool qt_debug_component(){#if defined(QT_DEBUG_COMPONENT)    return true;    //compatibility?#else    static int debug_env = -1;    if (debug_env == -1)       debug_env = ::qgetenv("QT_DEBUG_PLUGINS").toInt();    return debug_env != 0;#endif}#endif // QT_NO_LIBRARY

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -