Skip to content
Snippets Groups Projects
Commit 6b8be12d authored by calrama's avatar calrama
Browse files

misc

parent fd2d5716
No related branches found
No related tags found
No related merge requests found
Pipeline #22925 passed
Pipeline: biotracker

#22930

    ---
    Language: Cpp
    TabWidth: 3
    IndentWidth: 3
    AccessModifierOffset: -3
    ConstructorInitializerIndentWidth: 0
    ContinuationIndentWidth: 3
    ColumnLimit: 79
    BinPackArguments: false
    BinPackParameters: false
    AlignAfterOpenBracket: Align
    AlignConsecutiveAssignments: true
    AlignConsecutiveDeclarations: true
    AlignOperands: true
    AlignEscapedNewlines: Right
    AlignTrailingComments: true
    PenaltyBreakAssignment: 100
    PenaltyBreakBeforeFirstCallParameter: 19
    PenaltyBreakComment: 300
    PenaltyBreakFirstLessLess: 120
    PenaltyBreakString: 1000
    PenaltyBreakTemplateDeclaration: 10
    PenaltyExcessCharacter: 1000000
    PenaltyReturnTypeOnItsOwnLine: 1000
    AllowAllArgumentsOnNextLine: false # clang-format >= 9
    AllowAllConstructorInitializersOnNextLine: false # clang-format >= 9
    AllowAllParametersOfDeclarationOnNextLine: false
    AllowShortBlocksOnASingleLine: false
    AllowShortCaseLabelsOnASingleLine: false
    AllowShortFunctionsOnASingleLine: All
    AllowShortIfStatementsOnASingleLine: false
    AllowShortLoopsOnASingleLine: false
    AlwaysBreakAfterDefinitionReturnType: None
    AlwaysBreakAfterReturnType: None
    AlwaysBreakBeforeMultilineStrings: false
    AlwaysBreakTemplateDeclarations: true
    BreakBeforeBraces: Custom
    BraceWrapping:
    AfterClass: true
    AfterControlStatement: false
    AfterEnum: false
    AfterFunction: true
    AfterNamespace: true
    AfterObjCDeclaration: false
    AfterStruct: true
    AfterUnion: false
    AfterExternBlock: false
    BeforeCatch: false
    BeforeElse: false
    IndentBraces: false
    SplitEmptyFunction: true
    SplitEmptyRecord: true
    SplitEmptyNamespace: true
    BreakBeforeBinaryOperators: None
    BreakBeforeInheritanceComma: false
    BreakInheritanceList: BeforeColon
    BreakBeforeTernaryOperators: true
    BreakConstructorInitializers: BeforeComma
    BreakAfterJavaFieldAnnotations: false
    BreakStringLiterals: true
    CommentPragmas: '^ IWYU pragma:'
    CompactNamespaces: false
    ConstructorInitializerAllOnOneLineOrOnePerLine: false
    Cpp11BracedListStyle: true
    DerivePointerAlignment: false
    DisableFormat: false
    ExperimentalAutoDetectBinPacking: false
    FixNamespaceComments: false
    ForEachMacros:
    - foreach
    - Q_FOREACH
    - BOOST_FOREACH
    IncludeBlocks: Preserve
    IncludeCategories:
    - Regex: '^"(llvm|llvm-c|clang|clang-c)/'
    Priority: 2
    - Regex: '^(<|"(gtest|gmock|isl|json)/)'
    Priority: 3
    - Regex: '.*'
    Priority: 1
    IncludeIsMainRegex: '(Test)?$'
    IndentCaseLabels: false
    IndentPPDirectives: None
    IndentWrappedFunctionNames: false
    JavaScriptQuotes: Leave
    JavaScriptWrapImports: true
    KeepEmptyLinesAtTheStartOfBlocks: true
    MacroBlockBegin: ''
    MacroBlockEnd: ''
    MaxEmptyLinesToKeep: 1
    NamespaceIndentation: All
    ObjCBinPackProtocolList: Auto
    ObjCBlockIndentWidth: 2
    ObjCSpaceAfterProperty: false
    ObjCSpaceBeforeProtocolList: true
    PointerAlignment: Left
    ReflowComments: true
    SortIncludes: false
    SortUsingDeclarations: true
    SpaceAfterCStyleCast: true
    SpaceAfterTemplateKeyword: false
    SpaceBeforeAssignmentOperators: true
    SpaceBeforeCpp11BracedList: false
    SpaceBeforeCtorInitializerColon: true
    SpaceBeforeInheritanceColon: true
    SpaceBeforeParens: ControlStatements
    SpaceBeforeRangeBasedForLoopColon: true
    SpaceInEmptyParentheses: false
    SpacesBeforeTrailingComments: 1
    SpacesInAngles: false
    SpacesInContainerLiterals: false
    SpacesInCStyleCastParentheses: false
    SpacesInParentheses: false
    SpacesInSquareBrackets: false
    Standard: Cpp11
    StatementMacros:
    - Q_UNUSED
    - QT_REQUIRE_VERSION
    UseTab: ForIndentation
    ...
    build
    .vscode
    [style]
    align_closing_bracket_with_visual_indent = true
    allow_multiline_lambdas = false
    allow_multiline_dictionary_keys = false
    allow_split_before_default_or_named_assigns = true
    allow_split_before_dict_value = true
    arithmetic_precedence_indication = false
    blank_line_before_nested_class_or_def = false
    blank_line_before_class_docstring = false
    blank_line_before_module_docstring = false
    blank_lines_around_top_level_definition = 2
    coalesce_brackets = false
    column_limit = 99
    continuation_align_style = 'space'
    continuation_indent_width = 4
    dedent_closing_brackets = true
    disable_ending_comma_heuristic = false
    each_dict_entry_on_separate_line = true
    i18n_comment = ''
    i18n_function_call = ''
    indent_dictionary_value = true
    indent_width = 4
    indent_blank_lines = false
    join_multiple_lines = true
    no_spaces_around_selected_binary_operators = set()
    space_between_ending_comma_and_closing_bracket = true
    spaces_around_power_operator = true
    spaces_around_default_or_named_assign = false
    spaces_before_comment = 2
    split_arguments_when_comma_terminated = false
    split_all_comma_separated_values = true
    split_before_arithmetic_operator = true
    split_before_bitwise_operator = true
    split_before_closing_bracket = true
    split_before_dict_set_generator = true
    split_before_dot = true
    split_before_expression_after_opening_paren = true
    split_before_first_argument = false
    split_before_logical_operator = true
    split_before_named_assigns = true
    split_complex_comprehension = true
    split_penalty_after_opening_bracket = 300
    split_penalty_after_unary_operator = 10000
    split_penalty_arithmetic_operator = 300
    split_penalty_before_if_expr = 0
    split_penalty_bitwise_operator = 300
    split_penalty_comprehension = 80
    split_penalty_excess_character = 7000
    split_penalty_for_added_line_split = 30
    split_penalty_import_names = 0
    split_penalty_logical_operator = 300
    use_tabs = false
    File moved
    ......@@ -16,7 +16,8 @@
    std::vector<std::string> QueryKey(HKEY hKey, std::string path)
    {
    //See https://docs.microsoft.com/en-us/windows/desktop/sysinfo/enumerating-registry-subkeys
    // See
    // https://docs.microsoft.com/en-us/windows/desktop/sysinfo/enumerating-registry-subkeys
    std::vector<std::string> list;
    TCHAR achClass[MAX_PATH] = TEXT(""); // buffer for class name
    DWORD cchClassName = MAX_PATH; // size of class string
    ......@@ -35,8 +36,7 @@ std::vector<std::string> QueryKey(HKEY hKey, std::string path)
    DWORD cchValue = MAX_VALUE_NAME;
    // Get the class name and the value count.
    retCode = RegQueryInfoKey(
    hKey, // key handle
    retCode = RegQueryInfoKey(hKey, // key handle
    achClass, // buffer for class name
    &cchClassName, // size of class string
    NULL, // reserved
    ......@@ -50,37 +50,35 @@ std::vector<std::string> QueryKey(HKEY hKey, std::string path)
    &ftLastWriteTime); // last write time
    // Enumerate the key values.
    if (cValues)
    {
    if (cValues) {
    // printf( "\nNumber of values: %d\n", cValues);
    for (i=0, retCode=ERROR_SUCCESS; i<cValues; i++)
    {
    for (i = 0, retCode = ERROR_SUCCESS; i < cValues; i++) {
    cchValue = MAX_VALUE_NAME;
    achValue[0] = '\0';
    retCode = RegEnumValue(hKey, i,
    achValue,
    &cchValue,
    NULL,
    NULL,
    NULL,
    NULL);
    if (retCode == ERROR_SUCCESS )
    {
    retCode =
    RegEnumValue(hKey, i, achValue, &cchValue, NULL, NULL, NULL, NULL);
    if (retCode == ERROR_SUCCESS) {
    CRegKey regKey;
    CHAR szBuffer[512];
    ULONG dwBufferSize = sizeof(szBuffer);
    if(auto error_code = regKey.Open(HKEY_LOCAL_MACHINE, path.c_str(), KEY_READ); error_code != ERROR_SUCCESS)
    {
    qWarning() << "Error opening windows registry path " << path.c_str() << ": " << error_code;
    if (auto error_code = regKey.Open(HKEY_LOCAL_MACHINE,
    path.c_str(),
    KEY_READ);
    error_code != ERROR_SUCCESS) {
    qWarning() << "Error opening windows registry path "
    << path.c_str() << ": " << error_code;
    regKey.Close();
    continue;
    }
    if(auto error_code = regKey.QueryStringValue(achValue,szBuffer,&dwBufferSize); error_code != ERROR_SUCCESS)
    {
    qWarning() << "Error opening windows registry value " << achValue << ": " << error_code;
    if (auto error_code = regKey.QueryStringValue(achValue,
    szBuffer,
    &dwBufferSize);
    error_code != ERROR_SUCCESS) {
    qWarning() << "Error opening windows registry value "
    << achValue << ": " << error_code;
    regKey.Close();
    continue;
    }
    ......@@ -106,8 +104,7 @@ std::vector<std::string> PluginLoader::queryRegistryBehaviors(std::string path)
    TEXT(path.c_str()),
    0,
    KEY_READ,
    &hTestKey) == ERROR_SUCCESS)
    {
    &hTestKey) == ERROR_SUCCESS) {
    list = QueryKey(hTestKey, path);
    }
    ......@@ -122,16 +119,14 @@ const char * WinGetEnv(const char * name)
    {
    const DWORD buffSize = 65535;
    static char buffer[buffSize];
    if (GetEnvironmentVariableA(name, buffer, buffSize))
    {
    if (GetEnvironmentVariableA(name, buffer, buffSize)) {
    return buffer;
    }
    else
    {
    } else {
    return 0;
    }
    }
    bool WinSetEnv(const char* name, const char* toWhat){
    bool WinSetEnv(const char* name, const char* toWhat)
    {
    return SetEnvironmentVariableA(name, toWhat);
    }
    #endif
    ......@@ -148,7 +143,8 @@ const char* PluginLoader::addDllPath(std::string f)
    // This way dependencies can be shipped in the same directory
    #ifdef _WIN32
    QFileInfo finf(f.c_str());
    //rather than the buggy _getenv: https://docs.microsoft.com/de-de/windows/desktop/api/winbase/nf-winbase-getenvironmentvariable
    // rather than the buggy _getenv:
    // https://docs.microsoft.com/de-de/windows/desktop/api/winbase/nf-winbase-getenvironmentvariable
    auto old_path = WinGetEnv("PATH");
    auto path = std::ostringstream();
    if (old_path) {
    ......@@ -163,7 +159,8 @@ const char* PluginLoader::addDllPath(std::string f)
    return "";
    }
    void PluginLoader::delDllPath(const char* oldPath){
    void PluginLoader::delDllPath(const char* oldPath)
    {
    // reset path. We don't want some weird cross-effects
    #ifdef _WIN32
    if (oldPath) {
    ......@@ -176,50 +173,45 @@ bool endsWith(std::string value, std::string ending)
    {
    std::transform(value.begin(), value.end(), value.begin(), ::tolower);
    std::transform(ending.begin(), ending.end(), ending.begin(), ::tolower);
    if (ending.size() > value.size()) return false;
    if (ending.size() > value.size())
    return false;
    return std::equal(ending.rbegin(), ending.rend(), value.rbegin());
    }
    bool validSuffix(std::string f, std::string suffix){
    bool validSuffix(std::string f, std::string suffix)
    {
    return (endsWith(f, suffix + ".dll") || endsWith(f, suffix + ".so"));
    }
    std::vector<std::string> PluginLoader::searchDirectoriesForPlugins(std::vector<std::string> list, std::string suffix){
    std::vector<std::string> PluginLoader::searchDirectoriesForPlugins(
    std::vector<std::string> list,
    std::string suffix)
    {
    // Search directories
    std::vector<std::string> filesFromFolders;
    for (auto f: list)
    {
    for (auto f : list) {
    auto path = std::filesystem::path(f);
    if (path.empty())
    {
    if (path.empty()) {
    continue;
    }
    if (std::filesystem::is_directory(path))
    {
    try
    {
    for (auto& e : std::filesystem::directory_iterator(path))
    {
    if (std::filesystem::is_directory(path)) {
    try {
    for (auto& e : std::filesystem::directory_iterator(path)) {
    auto p = e.path();
    if (is_shared_library(p) && p.replace_extension().extension() == suffix)
    {
    if (is_shared_library(p) &&
    p.replace_extension().extension() == suffix) {
    filesFromFolders.push_back(e.path().string());
    }
    }
    }
    catch (std::filesystem::filesystem_error const& e)
    {
    } catch (std::filesystem::filesystem_error const& e) {
    qWarning() << e.what();
    }
    }
    else if (is_shared_library(path))
    {
    } else if (is_shared_library(path)) {
    filesFromFolders.push_back(f);
    }
    else
    {
    qWarning() << "Neither a directory, nor a shared library:" << f.data();
    } else {
    qWarning() << "Neither a directory, nor a shared library:"
    << f.data();
    }
    }
    ......@@ -259,14 +251,12 @@ bool PluginLoader::loadPluginFromFilename(QString const& filename)
    std::string ss = s.toStdString();
    addPluginnameToLists(getCurrentPluginName(), filename);
    if (!m_PluginLoader->isLoaded())
    {
    if (!m_PluginLoader->isLoaded()) {
    qWarning() << ss.c_str();
    retval = false;
    }
    PluginLoader::delDllPath(oldPath);
    }
    else {
    } else {
    retval = false;
    }
    ......@@ -281,12 +271,14 @@ void PluginLoader::addPluginnameToLists(QString mstring, QString filename)
    m_PluginMap.insert(std::pair<QString, QString>(mstring, filename));
    }
    bool PluginLoader::loadPluginFromName(QString name) {
    bool PluginLoader::loadPluginFromName(QString name)
    {
    QString filename = m_PluginMap.find(name)->second;
    return loadPluginFromFilename(filename);
    }
    int PluginLoader::addToPluginList(QString filename, QString suffix) {
    int PluginLoader::addToPluginList(QString filename, QString suffix)
    {
    if (!validSuffix(filename.toStdString(), suffix.toStdString()))
    return 1;
    ......@@ -300,19 +292,17 @@ int PluginLoader::addToPluginList(QString filename, QString suffix) {
    QJsonObject metaObj = pluginMeda.toObject();
    QString mstring = metaObj.value("name").toString();
    addPluginnameToLists(mstring, filename);
    }
    else {
    } else {
    return 2;
    qWarning() << "Error reading plugin: " << filename;
    }
    return 0;
    }
    QStringListModel* PluginLoader::getPluginList() {
    return m_PluginListModel;
    }
    QStringListModel* PluginLoader::getPluginList() { return m_PluginListModel; }
    QObject* PluginLoader::getPluginInstance() {
    QObject* PluginLoader::getPluginInstance()
    {
    return (m_PluginLoader->instance());
    }
    ......@@ -325,14 +315,14 @@ QJsonObject PluginLoader::getPluginMetaData() const
    void PluginLoader::readMetaDataFromPlugin()
    {
    m_MetaData = std::make_shared<QJsonObject>(m_PluginLoader->metaData().value("MetaData").toObject());
    m_MetaData = std::make_shared<QJsonObject>(
    m_PluginLoader->metaData().value("MetaData").toObject());
    }
    bool PluginLoader::getIsPluginLoaded() {
    return m_isPluginLoaded;
    }
    bool PluginLoader::getIsPluginLoaded() { return m_isPluginLoaded; }
    QString PluginLoader::getCurrentPluginName() {
    QString PluginLoader::getCurrentPluginName()
    {
    if (m_MetaData == nullptr)
    return "Error name";
    return m_MetaData->value("name").toString();
    ......@@ -341,6 +331,3 @@ const std::map<QString, QString> &PluginLoader::getPluginMap() const
    {
    return m_PluginMap;
    }
    ......@@ -10,8 +10,8 @@
    /**
    * \class PluginLoader
    * This class loads Qt-Plugins, the related metadata and files the plugin depends on.
    * \author Hauke Mönck, Gregor Barth
    * This class loads Qt-Plugins, the related metadata and files the plugin
    * depends on. \author Hauke Mönck, Gregor Barth
    */
    class PluginLoader : QObject
    ......@@ -24,8 +24,9 @@ public:
    /**
    * Loads a file as a QT plugin and reads it's name from the metadata.
    * It will then be added to the stringlist and is selectable via "loadPluginFromName".
    * This function does not actually set the plugin instance.
    * It will then be added to the stringlist and is selectable via
    * "loadPluginFromName". This function does not actually set the plugin
    * instance.
    */
    int addToPluginList(QString filename, QString suffix);
    ......@@ -35,15 +36,16 @@ public:
    QStringListModel* getPluginList();
    /**
    * Loads a BioTracker Plugin from a file path. It returns true if the Plugin could be loaded, otherwise false.
    * The loaded plugin acts as singleton!
    * Loads a BioTracker Plugin from a file path. It returns true if the Plugin
    * could be loaded, otherwise false. The loaded plugin acts as singleton!
    */
    bool loadPluginFromFilename(QString const& filename);
    /**
    * Loads a plugin from it's name (given in the metadata) instead of the filename.
    * Only works if it is already known to the pluginloader, i.e. was loaded manually or automatically before or
    * or has been added to the pluginlist via "addToPluginList"
    * Loads a plugin from it's name (given in the metadata) instead of the
    * filename. Only works if it is already known to the pluginloader, i.e. was
    * loaded manually or automatically before or or has been added to the
    * pluginlist via "addToPluginList"
    */
    bool loadPluginFromName(QString name);
    ......@@ -51,7 +53,9 @@ public:
    static std::vector<std::string> queryRegistryBehaviors(std::string path);
    static std::vector<std::string> searchDirectoriesForPlugins(std::vector<std::string> list, std::string suffix);
    static std::vector<std::string> searchDirectoriesForPlugins(
    std::vector<std::string> list,
    std::string suffix);
    // return oldPath
    static const char* addDllPath(std::string file);
    ......@@ -75,7 +79,6 @@ public:
    std::map<QString, QString> const& getPluginMap() const;
    private:
    void addPluginnameToLists(QString name, QString filename);
    // a map containing the mapping "plugin name -> filename"
    ......@@ -98,7 +101,8 @@ private:
    // List of all available plugins
    QStringList m_PluginList;
    // Entire ListModel of the metadata (actually containing all metadata, not only name)
    // Entire ListModel of the metadata (actually containing all metadata, not
    // only name)
    QStringListModel* m_PluginListModel;
    };
    ......
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment