From 813f7bbe7657cb3d1fa03326b3d1441b889ced36 Mon Sep 17 00:00:00 2001
From: Giovanni Bussi <giovanni.bussi@gmail.com>
Date: Mon, 3 Oct 2016 16:28:30 +0200
Subject: [PATCH] Added method to find a keyword

This finds a keyword in a list without erasing it.
---
 src/tools/Tools.cpp | 9 +++++++++
 src/tools/Tools.h   | 2 ++
 2 files changed, 11 insertions(+)

diff --git a/src/tools/Tools.cpp b/src/tools/Tools.cpp
index c143889a3..b51ed3781 100644
--- a/src/tools/Tools.cpp
+++ b/src/tools/Tools.cpp
@@ -321,5 +321,14 @@ bool Tools::startWith(const std::string & full,const std::string &start){
   return (full.substr(0,start.length())==start);
 }
 
+bool Tools::findKeyword(const std::vector<std::string>&line,const std::string&key){
+  const std::string search(key+"=");
+  for(vector<string>::const_iterator p=line.begin();p!=line.end();++p){
+    if(startWith(*p,search)) return true;
+  }
+  return false;
+}
+
+
 
 }
diff --git a/src/tools/Tools.h b/src/tools/Tools.h
index dbe7f3ded..bb9153adb 100644
--- a/src/tools/Tools.h
+++ b/src/tools/Tools.h
@@ -110,6 +110,8 @@ public:
   static bool parseVector(std::vector<std::string>&line,const std::string&key,std::vector<T>&val);
 /// Find a keyword without arguments on the input line
   static bool parseFlag(std::vector<std::string>&line,const std::string&key,bool&val);
+/// Find a keyword on the input line, just reporting if it exists or not
+  static bool findKeyword(const std::vector<std::string>&line,const std::string&key);
 /// Interpret atom ranges
   static void interpretRanges(std::vector<std::string>&);
 /// Remove duplicates from a vector of type T 
-- 
GitLab