From 00e180dd437cb3215eb08a93fc748531e68ef774 Mon Sep 17 00:00:00 2001
From: Marcel Loose <loose@astron.nl>
Date: Wed, 26 Nov 2008 10:45:19 +0000
Subject: [PATCH] Bug 1287: Removed the pqutil stuff

---
 .../BBSControl/include/BBSControl/Makefile.am |   1 -
 CEP/BB/BBSControl/include/BBSControl/pqutil.h |  73 ----------
 CEP/BB/BBSControl/src/Makefile.am             |   1 -
 CEP/BB/BBSControl/src/pqutil.cc               | 127 ------------------
 CEP/BB/BBSControl/test/Makefile.am            |  13 +-
 CEP/BB/BBSControl/test/tpqutil.cc             | 119 ----------------
 CEP/BB/BBSControl/test/tpqutil.parset         |   7 -
 CEP/BB/BBSControl/test/tpqutil.sh             |   2 -
 8 files changed, 3 insertions(+), 340 deletions(-)
 delete mode 100644 CEP/BB/BBSControl/include/BBSControl/pqutil.h
 delete mode 100644 CEP/BB/BBSControl/src/pqutil.cc
 delete mode 100644 CEP/BB/BBSControl/test/tpqutil.cc
 delete mode 100644 CEP/BB/BBSControl/test/tpqutil.parset
 delete mode 100755 CEP/BB/BBSControl/test/tpqutil.sh

diff --git a/CEP/BB/BBSControl/include/BBSControl/Makefile.am b/CEP/BB/BBSControl/include/BBSControl/Makefile.am
index f77f866f932..ae78d6023b9 100644
--- a/CEP/BB/BBSControl/include/BBSControl/Makefile.am
+++ b/CEP/BB/BBSControl/include/BBSControl/Makefile.am
@@ -35,7 +35,6 @@ pkginclude_HEADERS = Package__Version.h  \
 	Types.h
 
 noinst_HEADERS = \
-	pqutil.h \
 	QueryBuilder/AddCommand.h \
 	StreamUtil.h
 
diff --git a/CEP/BB/BBSControl/include/BBSControl/pqutil.h b/CEP/BB/BBSControl/include/BBSControl/pqutil.h
deleted file mode 100644
index 61d712dd33b..00000000000
--- a/CEP/BB/BBSControl/include/BBSControl/pqutil.h
+++ /dev/null
@@ -1,73 +0,0 @@
-//#  pqutil.h: PostgreSQL related utilities; for internal use only.
-//#
-//#  Copyright (C) 2002-2004
-//#  ASTRON (Netherlands Foundation for Research in Astronomy)
-//#  P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
-//#
-//#  This program is free software; you can redistribute it and/or modify
-//#  it under the terms of the GNU General Public License as published by
-//#  the Free Software Foundation; either version 2 of the License, or
-//#  (at your option) any later version.
-//#
-//#  This program is distributed in the hope that it will be useful,
-//#  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//#  GNU General Public License for more details.
-//#
-//#  You should have received a copy of the GNU General Public License
-//#  along with this program; if not, write to the Free Software
-//#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-//#
-//#  $Id$
-
-#ifndef LOFAR_BBSCONTROL_PQUTIL_H
-#define LOFAR_BBSCONTROL_PQUTIL_H
-
-//# Never #include <config.h> or #include <lofar_config.h> in a header file!
-
-// \file
-// PostgreSQL related utilities; for internal use only.
-
-//# Includes
-#include <Common/lofar_string.h>
-#include <Common/lofar_vector.h>
-
-namespace LOFAR
-{
-  namespace BBS
-  {
-    // \addtogroup BBSControl
-    // @{
-      
-    // \internal
-    // Convert a Postgres-generated C-string to a ParameterSet string. For
-    // vectors, this means replacing '{' with '[' and '}' with ']'.
-    // @{
-    string toPSstring(const char* in);
-    string toPSstring(const string& in);
-    // @}
-
-    // \internal
-    // Convert a ParameterSet string to a Postgres string:
-    // - single quotes will be escaped by doubling them;
-    // - curly braces and double quotes will be escaped using a backslash.
-    // - vector delimiters \c [ and \c ] will be replaced with \c { and \c }.
-    // @{
-    string toPQstring(const string& in);
-    string toPQstring(const vector<string>& in);
-    // @}
-
-    // @}
-
-    //##----   I n l i n e   m e t h o d s   ----##//
-
-    inline string toPSstring(const string& in)
-    {
-      return toPSstring(in.c_str());
-    }
-
-  } // namespace BBS
-  
-} // namespace LOFAR
-
-#endif
diff --git a/CEP/BB/BBSControl/src/Makefile.am b/CEP/BB/BBSControl/src/Makefile.am
index 72851d568c1..bf7de3232a5 100644
--- a/CEP/BB/BBSControl/src/Makefile.am
+++ b/CEP/BB/BBSControl/src/Makefile.am
@@ -18,7 +18,6 @@ libbbscontrol_la_SOURCES	= Package__Version.cc  \
 	MultiStep.cc \
 	NextChunkCommand.cc \
 	NoiseStep.cc \
-	pqutil.cc \
 	PredictStep.cc \
 	QueryBuilder/AddCommand.cc \
 	RecoverCommand.cc \
diff --git a/CEP/BB/BBSControl/src/pqutil.cc b/CEP/BB/BBSControl/src/pqutil.cc
deleted file mode 100644
index 5f2bf69c96a..00000000000
--- a/CEP/BB/BBSControl/src/pqutil.cc
+++ /dev/null
@@ -1,127 +0,0 @@
-//#  pqutil.cc: PostgreSQL related utilities; for internal use only.
-//#
-//#  Copyright (C) 2002-2004
-//#  ASTRON (Netherlands Foundation for Research in Astronomy)
-//#  P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
-//#
-//#  This program is free software; you can redistribute it and/or modify
-//#  it under the terms of the GNU General Public License as published by
-//#  the Free Software Foundation; either version 2 of the License, or
-//#  (at your option) any later version.
-//#
-//#  This program is distributed in the hope that it will be useful,
-//#  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//#  GNU General Public License for more details.
-//#
-//#  You should have received a copy of the GNU General Public License
-//#  along with this program; if not, write to the Free Software
-//#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-//#
-//#  $Id$
-
-//# Always #include <lofar_config.h> first!
-#include <lofar_config.h>
-
-//# Includes
-#include <BBSControl/pqutil.h>
-#include <Common/lofar_sstream.h>
-#include <BBSControl/StreamUtil.h>
-
-namespace LOFAR
-{
-  namespace BBS
-  {
-    string toPSstring(const char* in)
-    {
-      string out(in);
-
-      // When a backslash (\c \\) is read, \c bs is set to true. The next
-      // character will cause it to toggle to false again. The backslash and
-      // the character following it will be left untouched in the output.
-      bool bs(false);
-
-      // Toggle indicating whether we're inside a quoted string or not. A
-      // quoted string is a string delimited by double quotes ("). No
-      // character substitutions will be done within a quoted string.
-      bool q(false);
-
-      for (string::iterator it = out.begin(); it != out.end(); ++it) {
-	// If previous character was a backslash, skip current character.
-        if (bs) {
-          bs = false;
-          continue;
-        }
-	if (bs = *it == '\\') continue; // skip if current char is backslash
-
-	// Toggle if current char is a quote.
-  	if (*it == '"') q = !q;
-	if (!q) {            // we're not between quotes
-	  switch(*it) {
-	  case '{': *it = '['; break;
-	  case '}': *it = ']'; break;
-	  default: break;
-	  }
-	}
-      }
-      return out;
-    }
-
-
-    string toPQstring(const string& in)
-    {
-      string out;
-
-      // Toggle indicating whether we're inside a quoted string or not. A
-      // quoted string is a string delimited by double quotes (").
-      bool q(false);
-
-      for (string::const_iterator it = in.begin(); it != in.end(); ++it) {
-	switch(*it) {
-	case '\\' :  // backslash must be doubled
-	  out += "\\\\"; 
-	  break;
-	case '\'' :  // single quote must be doubled
-	  out += "''";
-	  break;
-	case '"'  :  // toggle quote character.
-	  q = !q;
-	  out += *it;
-	  break;
-	case '['  :  // replace '[' with '{' when not inside quoted string
-	  if (q) out += *it;
-	  else out += '{';
-	  break;
-	case ']'  :  // replace ']' with '}' when not inside quoted string
-	  if (q) out += *it;
-	  else out += '}';
-	  break;
-	case '{'  :  // '{' must be escaped when not inside quoted string
-	  if (!q) out += "\\\\";
-	  out += *it;
-	  break;
-	case '}'  :  // '}' must be escaped when not inside quoted string
-	  if (!q) out += "\\\\";
-	  out += *it;
-	  break;
-	default:
-	  out += *it;
-	  break;
-	}
-      }
-      return out;
-    }
-    
-
-    string toPQstring(const vector<string>& in)
-    {
-      ostringstream oss;
-      oss << in;
-      return toPQstring(oss.str());
-    }
-
-
-  } // namespace BBS
-  
-} // namespace LOFAR
-
diff --git a/CEP/BB/BBSControl/test/Makefile.am b/CEP/BB/BBSControl/test/Makefile.am
index 6036d6439a8..d903501aca7 100644
--- a/CEP/BB/BBSControl/test/Makefile.am
+++ b/CEP/BB/BBSControl/test/Makefile.am
@@ -1,21 +1,14 @@
-check_PROGRAMS			= tpqutil \
-				  tStrategy \
+check_PROGRAMS			= tStrategy \
 				  tCommandQueue
 
-check_SCRIPTS			= tpqutil.sh \
-				  tStrategy.sh \
+check_SCRIPTS			= tStrategy.sh \
 				  tCommandQueue.sh
 
 # programs to run through supplied checktools
-CHECKTOOLPROGS			= tpqutil \
-				  tStrategy \
+CHECKTOOLPROGS			= tStrategy \
 				  tCommandQueue
 #ENDCHECKTOOLPROGS
 
-tpqutil_SOURCES			= tpqutil.cc
-tpqutil_LDADD			= ../src/libbbscontrol.la
-tpqutil_DEPENDENCIES		= ../src/libbbscontrol.la $(LOFAR_DEPEND)
-
 tStrategy_SOURCES		= tStrategy.cc
 tStrategy_LDADD			= ../src/libbbscontrol.la
 tStrategy_DEPENDENCIES		= ../src/libbbscontrol.la $(LOFAR_DEPEND)
diff --git a/CEP/BB/BBSControl/test/tpqutil.cc b/CEP/BB/BBSControl/test/tpqutil.cc
deleted file mode 100644
index ee27970557d..00000000000
--- a/CEP/BB/BBSControl/test/tpqutil.cc
+++ /dev/null
@@ -1,119 +0,0 @@
-#include <lofar_config.h>
-#include <BBSControl/pqutil.h>
-#include <APS/ParameterSet.h>
-#include <Common/lofar_iostream.h>
-#include <Common/LofarLogger.h>
-
-using namespace LOFAR;
-using namespace LOFAR::BBS;
-using namespace LOFAR::ACC::APS;
-
-#if 0
-void toPQ(ostream& os, const ParameterSet& ps)
-{
-}
-
-void toPS(ostream& os, ParameterSet& ps)
-{
-}
-#endif
-
-int main()
-{
-  INIT_LOGGER("tutil");
-  ParameterSet ps("tpqutil.parset"); 
-  string s1(ps.getString("s1"));
-  vector<string> s2(ps.getStringVector("s2"));
-  vector<string> s3(ps.getStringVector("s3"));
-  string s4(ps.getString("s4"));
-  vector<string> s5(ps.getStringVector("s5"));
-  string s6(ps.getString("s6"));
-
-//   cout << "s1 = " << s1 << endl;
-//   cout << "s2 [" << s2.size() << "] = " << endl;
-//   for (uint i = 0; i < s2.size(); ++i) cout << "  " << s2[i] << endl;
-//   cout << "s3 [" << s3.size() << "] = " << endl;
-//   for (uint i = 0; i < s3.size(); ++i) cout << "  " << s3[i] << endl;
-//   cout << "s4 = " << s4 << endl;
-//   cout << "s5 [" << s5.size() << "] = " << endl;
-//   for (uint i = 0; i < s5.size(); ++i) cout << "  " << s5[i] << endl;
-//   cout << "s6 = " << s6 << endl;
-
-  string s;
-  cout << "\nOriginal:" << endl;
-  ps.writeBuffer(s);
-  cout << s << endl;
-
-  cout << "\nAs PSQL string:" << endl;
-  s = toPQstring(s);
-  cout << s << endl;
-
-  cout << "\nAs ParameterSet string:" << endl;
-  s = toPSstring(s.c_str());
-  cout << s << endl;
-
-  return 0;
-#if 1
-
-  // \note All backslashes must be doubled in the string initialization,
-  // because a backslash should be properly escaped using a backslash.
-  try {
-    cout << toPSstring("Hello, World") << endl;
-    cout << toPSstring("{Hello, World, Array}") << endl;
-    cout << toPSstring("{Curly braces, '{' and '}', must be quoted,") 
-	 << toPSstring(" or escaped like this: \\{ and \\}}") << endl;
-    cout << toPSstring("{Unbalanced braces do not throw") << endl;
-    cout << toPSstring("Properly escaped quote: \\',")
-	 << toPSstring(" and another: \\\\\\'") << endl;
-    cout << toPSstring("Trailing backslash \\") << endl;
-  }
-  catch (Exception& e) {
-    cerr << e << endl;
-    return 1;
-  }
-
-  try {
-    cout << toPSstring("Missing closing single quote ' will throw") << endl;
-    return 1;   // should not get here
-  }
-  catch (Exception& e) {
-    cout << "(Expected): " << e.what() << endl;
-  }
-
-  try {
-    cout << toPSstring("Missing closing double quote \" will throw") << endl;
-    return 1;   // should not get here
-  }
-  catch (Exception& e) {
-    cout << "(Expected): " << e.what() << endl;
-  }
-
-  try {
-    cout << toPSstring("Improperly escaped quote \\\\' will throw") << endl;
-    return 1;   // should not get here
-  }
-  catch (Exception& e) {
-    cout << "(Expected): " << e.what() << endl;
-  }
-
-#else
-
-  try {
-    cout << toPQstring("Hello, World") << endl;
-    cout << toPQstring("[Hello, World, Array]") << endl;
-    cout << toPQstring("Curly braces, \"{\" and \"}\", must be quoted,") 
- 	 << toPQstring(" or escaped like this: \\{ and \\}") << endl;
-    cout << toPQstring("[Unbalanced brackets do not throw") << endl;
-    cout << toPQstring("Properly escaped quote: \\',")
- 	 << toPQstring(" and another: \\\\\\'") << endl;
-    cout << toPQstring("Trailing backslash \\") << endl;
-  }
-  catch (Exception& e) {
-    cerr << e << endl;
-    return 1;
-  }
-
-#endif
-
-  return 0;
-}
diff --git a/CEP/BB/BBSControl/test/tpqutil.parset b/CEP/BB/BBSControl/test/tpqutil.parset
deleted file mode 100644
index c0a5ada1964..00000000000
--- a/CEP/BB/BBSControl/test/tpqutil.parset
+++ /dev/null
@@ -1,7 +0,0 @@
-s1=Hello, World
-s2=[Hello, World, Array]
-s3=[Brackets, "[ and ]", must be quoted]#, or escaped like this: \[ and \]]
-s4=[Unbalanced braces do not throw, but it's ugly
-s5=[Properly escaped quote: \", and another: \\\"]
-s6=Trailing backslash \
-.
diff --git a/CEP/BB/BBSControl/test/tpqutil.sh b/CEP/BB/BBSControl/test/tpqutil.sh
deleted file mode 100755
index e054584b917..00000000000
--- a/CEP/BB/BBSControl/test/tpqutil.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/sh
-$lofar_sharedir/runtest.sh tpqutil > tpqutil.log 2>&1
-- 
GitLab