Ver Fonte

[minor] compile warnings

isundil há 9 anos atrás
pai
commit
573a76573d

+ 4 - 1
include/curseOutput.hh

@@ -93,7 +93,10 @@ class CurseOutput
         /**
          * Write data
         **/
-        void write(const std::string &str, unsigned int maxWidth, const OutputFlag flags) const;
+        /**
+         * Warning: this one does not check line height, because he's not aware of cursor position
+        **/
+        void write(const std::string &str, const OutputFlag flags) const;
         unsigned int write(const int &x, const int &y, const JSonElement *item, unsigned int maxWidth, const OutputFlag);
         unsigned int write(const int &x, const int &y, const std::string &item, unsigned int maxWidth, const OutputFlag);
         unsigned int write(const int &x, const int &y, const char item, unsigned int maxWidth, const OutputFlag);

+ 1 - 1
include/params.hh

@@ -30,7 +30,7 @@ class AParams
 class Params: public AParams
 {
     public:
-        Params(int ac, char **av);
+        Params(char **av);
         virtual ~Params();
 
         /**

+ 2 - 2
include/streamConsumer.hh

@@ -32,8 +32,8 @@ class StreamConsumer
         /**
          * get root node
         **/
-        const JSonElement * const getRoot() const;
-        JSonElement * const getRoot();
+        const JSonElement * getRoot() const;
+        JSonElement * getRoot();
 
         /**
          * return non-blocking error messages

+ 5 - 6
src/curseOutput.cpp

@@ -247,8 +247,8 @@ bool CurseOutput::writeKey(const std::string &key, const std::string &after, std
     }
     if (!writeKey(key, cursor, maxSize, flags, after.size()))
         return false;
+    write(after.c_str(), flags);
     //TODO check result if write goes to new line
-    write(after.c_str(), maxSize.first, flags);
     return true;
 }
 
@@ -261,10 +261,9 @@ bool CurseOutput::writeKey(const std::string &key, std::pair<int, int> &cursor,
     }
     char oldType = flags.type();
     flags.type(OutputFlag::TYPE_OBJKEY);
-    write(cursor.first, cursor.second, key, maxSize.first -extraLen -2, flags);
-    cursor.second ++;
+    cursor.second += write(cursor.first, cursor.second, key, maxSize.first -extraLen -2, flags);
     flags.type(OutputFlag::TYPE_OBJ);
-    write(": ", maxSize.first, flags);
+    write(": ", flags);
     flags.type(oldType);
     return (cursor.second - scrollTop < 0 || (unsigned)(cursor.second - scrollTop) <= maxSize.second);
 }
@@ -297,7 +296,7 @@ unsigned int CurseOutput::write(const int &x, const int &y, const char item, uns
     return getNbLines(x +1, maxWidth);
 }
 
-void CurseOutput::write(const std::string &str, unsigned int maxWidth, const OutputFlag flags) const
+void CurseOutput::write(const std::string &str, const OutputFlag flags) const
 {
     char color = OutputFlag::SPECIAL_NONE;
     if (params.colorEnabled() && !search_pattern.empty() && str.find(search_pattern) != str.npos)
@@ -322,7 +321,7 @@ unsigned int CurseOutput::write(const int &x, const int &y, const std::string &s
     if (offsetY < 0)
         return 1;
     move(offsetY, x);
-    write(str, maxWidth, flags);
+    write(str, flags);
     return getNbLines(str.size() +x, maxWidth);
 }
 

+ 2 - 1
src/main.cpp

@@ -57,7 +57,8 @@ void run(Params *params)
 
 int main(int ac, char **av)
 {
-    Params *params = new Params(ac, av);
+    (void) ac;
+    Params *params = new Params(av);
     bool _run = false;
 
     try {

+ 1 - 1
src/params.cpp

@@ -13,7 +13,7 @@
 
 #include "config.h"
 
-Params::Params(int ac, char **av) :progName(*av), strict(true)
+Params::Params(char **av) :progName(*av), strict(true)
 {
     av++;
     while (*av)

+ 2 - 2
src/streamConsumer.cpp

@@ -53,10 +53,10 @@ JSonElement *StreamConsumer::readNext(JSonContainer *parent)
     return root;
 }
 
-const JSonElement * const StreamConsumer::getRoot() const
+const JSonElement * StreamConsumer::getRoot() const
 { return root; }
 
-JSonElement * const StreamConsumer::getRoot()
+JSonElement * StreamConsumer::getRoot()
 { return root; }
 
 JSonObject *StreamConsumer::readObject(JSonContainer *parent)

+ 1 - 1
test/src/main.cpp

@@ -116,7 +116,7 @@ void checkSample()
     delete root;
 }
 
-int main(int ac, char **av)
+int main()
 {
     checkTypes();
     checkArray();