Logo Search packages:      
Sourcecode: virtualbox-ose version File versions

bool VirtualBoxSupportTranslationBase::cutClassNameFrom__PRETTY_FUNCTION__ ( char *  fn  )  [static, protected]

Modifies the given argument so that it will contain only a class name (null-terminated). The argument must point to a non-constant string containing a valid value, as it is generated by the __PRETTY_FUNCTION__ built-in macro of the GCC compiler, or by the __FUNCTION__ macro of any other compiler.

The function assumes that the macro is used within the member of the class derived from the VirtualBoxSupportTranslation<> template.

prettyFunctionName string to modify
true on success and false otherwise

Definition at line 694 of file VirtualBoxBase.cpp.

References Assert.

    Assert (fn);
    if (!fn)
        return false;

#if defined (__GNUC__)

    // the format is like:
    // VirtualBoxSupportTranslation<C>::VirtualBoxSupportTranslation() [with C = VirtualBox]

    #define START " = "
    #define END   "]"

#elif defined (_MSC_VER)

    // the format is like:
    // VirtualBoxSupportTranslation<class VirtualBox>::__ctor

    #define START "<class "
    #define END   ">::"


    char *start = strstr (fn, START);
    Assert (start);
    if (start)
        start += sizeof (START) - 1;
        char *end = strstr (start, END);
        Assert (end && (end > start));
        if (end && (end > start))
            size_t len = end - start;
            memmove (fn, start, len);
            fn [len] = 0;
            return true;

    #undef END
    #undef START

    return false;

Generated by  Doxygen 1.6.0   Back to index