Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 54ce72ca authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Use const refs to strings in PropertyProvider" into udc-dev am: ee66b97f

parents 09c5c52f ee66b97f
Loading
Loading
Loading
Loading
+6 −6
Original line number Original line Diff line number Diff line
@@ -68,11 +68,11 @@ const GesturesPropProvider gesturePropProvider = {
        .free_fn = freeProperty,
        .free_fn = freeProperty,
};
};


bool PropertyProvider::hasProperty(const std::string name) const {
bool PropertyProvider::hasProperty(const std::string& name) const {
    return mProperties.find(name) != mProperties.end();
    return mProperties.find(name) != mProperties.end();
}
}


GesturesProp& PropertyProvider::getProperty(const std::string name) {
GesturesProp& PropertyProvider::getProperty(const std::string& name) {
    return mProperties.at(name);
    return mProperties.at(name);
}
}


@@ -84,7 +84,7 @@ std::string PropertyProvider::dump() const {
    return dump;
    return dump;
}
}


GesturesProp* PropertyProvider::createIntArrayProperty(const std::string name, int* loc,
GesturesProp* PropertyProvider::createIntArrayProperty(const std::string& name, int* loc,
                                                       size_t count, const int* init) {
                                                       size_t count, const int* init) {
    const auto [it, inserted] =
    const auto [it, inserted] =
            mProperties.insert(std::pair{name, GesturesProp(name, loc, count, init)});
            mProperties.insert(std::pair{name, GesturesProp(name, loc, count, init)});
@@ -92,7 +92,7 @@ GesturesProp* PropertyProvider::createIntArrayProperty(const std::string name, i
    return &it->second;
    return &it->second;
}
}


GesturesProp* PropertyProvider::createBoolArrayProperty(const std::string name,
GesturesProp* PropertyProvider::createBoolArrayProperty(const std::string& name,
                                                        GesturesPropBool* loc, size_t count,
                                                        GesturesPropBool* loc, size_t count,
                                                        const GesturesPropBool* init) {
                                                        const GesturesPropBool* init) {
    const auto [it, inserted] =
    const auto [it, inserted] =
@@ -101,7 +101,7 @@ GesturesProp* PropertyProvider::createBoolArrayProperty(const std::string name,
    return &it->second;
    return &it->second;
}
}


GesturesProp* PropertyProvider::createRealArrayProperty(const std::string name, double* loc,
GesturesProp* PropertyProvider::createRealArrayProperty(const std::string& name, double* loc,
                                                        size_t count, const double* init) {
                                                        size_t count, const double* init) {
    const auto [it, inserted] =
    const auto [it, inserted] =
            mProperties.insert(std::pair{name, GesturesProp(name, loc, count, init)});
            mProperties.insert(std::pair{name, GesturesProp(name, loc, count, init)});
@@ -109,7 +109,7 @@ GesturesProp* PropertyProvider::createRealArrayProperty(const std::string name,
    return &it->second;
    return &it->second;
}
}


GesturesProp* PropertyProvider::createStringProperty(const std::string name, const char** loc,
GesturesProp* PropertyProvider::createStringProperty(const std::string& name, const char** loc,
                                                     const char* const init) {
                                                     const char* const init) {
    const auto [it, inserted] = mProperties.insert(std::pair{name, GesturesProp(name, loc, init)});
    const auto [it, inserted] = mProperties.insert(std::pair{name, GesturesProp(name, loc, init)});
    LOG_ALWAYS_FATAL_IF(!inserted, "Gesture property \"%s\" already exists.", name.c_str());
    LOG_ALWAYS_FATAL_IF(!inserted, "Gesture property \"%s\" already exists.", name.c_str());
+6 −6
Original line number Original line Diff line number Diff line
@@ -31,18 +31,18 @@ extern const GesturesPropProvider gesturePropProvider;
// Implementation of a gestures library property provider, which provides configuration parameters.
// Implementation of a gestures library property provider, which provides configuration parameters.
class PropertyProvider {
class PropertyProvider {
public:
public:
    bool hasProperty(const std::string name) const;
    bool hasProperty(const std::string& name) const;
    GesturesProp& getProperty(const std::string name);
    GesturesProp& getProperty(const std::string& name);
    std::string dump() const;
    std::string dump() const;


    // Methods to be called by the gestures library:
    // Methods to be called by the gestures library:
    GesturesProp* createIntArrayProperty(const std::string name, int* loc, size_t count,
    GesturesProp* createIntArrayProperty(const std::string& name, int* loc, size_t count,
                                         const int* init);
                                         const int* init);
    GesturesProp* createBoolArrayProperty(const std::string name, GesturesPropBool* loc,
    GesturesProp* createBoolArrayProperty(const std::string& name, GesturesPropBool* loc,
                                          size_t count, const GesturesPropBool* init);
                                          size_t count, const GesturesPropBool* init);
    GesturesProp* createRealArrayProperty(const std::string name, double* loc, size_t count,
    GesturesProp* createRealArrayProperty(const std::string& name, double* loc, size_t count,
                                          const double* init);
                                          const double* init);
    GesturesProp* createStringProperty(const std::string name, const char** loc,
    GesturesProp* createStringProperty(const std::string& name, const char** loc,
                                       const char* const init);
                                       const char* const init);


    void freeProperty(GesturesProp* prop);
    void freeProperty(GesturesProp* prop);