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

Commit 7ddd5ddf 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 87428bc0 ee66b97f
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -68,11 +68,11 @@ const GesturesPropProvider gesturePropProvider = {
        .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();
}

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

@@ -84,7 +84,7 @@ std::string PropertyProvider::dump() const {
    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) {
    const auto [it, inserted] =
            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;
}

GesturesProp* PropertyProvider::createBoolArrayProperty(const std::string name,
GesturesProp* PropertyProvider::createBoolArrayProperty(const std::string& name,
                                                        GesturesPropBool* loc, size_t count,
                                                        const GesturesPropBool* init) {
    const auto [it, inserted] =
@@ -101,7 +101,7 @@ GesturesProp* PropertyProvider::createBoolArrayProperty(const std::string name,
    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) {
    const auto [it, inserted] =
            mProperties.insert(std::pair{name, GesturesProp(name, loc, count, init)});
@@ -109,7 +109,7 @@ GesturesProp* PropertyProvider::createRealArrayProperty(const std::string name,
    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 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());
+6 −6
Original line number Diff line number Diff line
@@ -31,18 +31,18 @@ extern const GesturesPropProvider gesturePropProvider;
// Implementation of a gestures library property provider, which provides configuration parameters.
class PropertyProvider {
public:
    bool hasProperty(const std::string name) const;
    GesturesProp& getProperty(const std::string name);
    bool hasProperty(const std::string& name) const;
    GesturesProp& getProperty(const std::string& name);
    std::string dump() const;

    // 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);
    GesturesProp* createBoolArrayProperty(const std::string name, GesturesPropBool* loc,
    GesturesProp* createBoolArrayProperty(const std::string& name, GesturesPropBool* loc,
                                          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);
    GesturesProp* createStringProperty(const std::string name, const char** loc,
    GesturesProp* createStringProperty(const std::string& name, const char** loc,
                                       const char* const init);

    void freeProperty(GesturesProp* prop);