[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libcvd-members] gvars3 Makefile.in configure configure.ac gvars...
From: |
Edward Rosten |
Subject: |
[libcvd-members] gvars3 Makefile.in configure configure.ac gvars... |
Date: |
Mon, 20 Apr 2009 14:59:39 +0000 |
CVSROOT: /cvsroot/libcvd
Module name: gvars3
Changes by: Edward Rosten <edrosten> 09/04/20 14:59:39
Modified files:
. : Makefile.in configure configure.ac
gvars3 : gv3_implementation.hh gvars3.h serialize.h
src : gvars2.cc serialize.cc
Removed files:
src : serialize_toon.cc
Log message:
Maybe works with TooN2?
Fixed up new serialization.
Removed parts of GVars2 compatibility which are incompatible with TooN2.
Vector<-1> will fail nastily.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gvars3/Makefile.in?cvsroot=libcvd&r1=1.28&r2=1.29
http://cvs.savannah.gnu.org/viewcvs/gvars3/configure?cvsroot=libcvd&r1=1.21&r2=1.22
http://cvs.savannah.gnu.org/viewcvs/gvars3/configure.ac?cvsroot=libcvd&r1=1.20&r2=1.21
http://cvs.savannah.gnu.org/viewcvs/gvars3/gvars3/gv3_implementation.hh?cvsroot=libcvd&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/gvars3/gvars3/gvars3.h?cvsroot=libcvd&r1=1.21&r2=1.22
http://cvs.savannah.gnu.org/viewcvs/gvars3/gvars3/serialize.h?cvsroot=libcvd&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/gvars3/src/gvars2.cc?cvsroot=libcvd&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/gvars3/src/serialize.cc?cvsroot=libcvd&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/gvars3/src/serialize_toon.cc?cvsroot=libcvd&r1=1.1&r2=0
Patches:
Index: Makefile.in
===================================================================
RCS file: /cvsroot/libcvd/gvars3/Makefile.in,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -b -r1.28 -r1.29
--- Makefile.in 20 Apr 2009 12:59:19 -0000 1.28
+++ Makefile.in 20 Apr 2009 14:59:38 -0000 1.29
@@ -107,11 +107,6 @@
OBJS+=src/GUI_impl_noreadline.o
endif
-ifeq (@have_toon@,yes)
- OBJS+=src/serialize_toon.o
- HEADLESSOBJS+=src/serialize_toon.o
-endif
-
#src/@address@hidden \
#G++ seems to run constructors in the reverse order
#so inst needs to be last.
Index: configure
===================================================================
RCS file: /cvsroot/libcvd/gvars3/configure,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- configure 20 Apr 2009 12:59:20 -0000 1.21
+++ configure 20 Apr 2009 14:59:38 -0000 1.22
@@ -3486,6 +3486,54 @@
{ echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6; }
fi
+
+ { echo "$as_me:$LINENO: checking for TooN-2" >&5
+echo $ECHO_N "checking for TooN-2... $ECHO_C" >&6; }
+
+ a=
+ cat >conftest.$ac_ext <<_ACEOF
+#include <TooN/TooN.h>
+int main(){TooN::Vector<2, float> v;return 0;}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_cxx_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ a=1
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+ if test x$a = x1
+ then
+ { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+ cat >>confdefs.h <<\_ACEOF
+#define GVARS3_HAVE_TOON2 1
+_ACEOF
+
+ else
+ { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+ fi
fi
Index: configure.ac
===================================================================
RCS file: /cvsroot/libcvd/gvars3/configure.ac,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- configure.ac 20 Apr 2009 12:59:20 -0000 1.20
+++ configure.ac 20 Apr 2009 14:59:38 -0000 1.21
@@ -100,6 +100,20 @@
else
AC_MSG_RESULT(no)
fi
+
+ AC_MSG_CHECKING([for TooN-2])
+
+ a=
+ AC_COMPILE_IFELSE([#include <TooN/TooN.h>
+int main(){TooN::Vector<2, float> v;return 0;}], [a=1])
+
+ if test x$a = x1
+ then
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(GVARS3_HAVE_TOON2)
+ else
+ AC_MSG_RESULT(no)
+ fi
fi
TEST_AND_SET_CXXFLAG(-pthread)
Index: gvars3/gv3_implementation.hh
===================================================================
RCS file: /cvsroot/libcvd/gvars3/gvars3/gv3_implementation.hh,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- gvars3/gv3_implementation.hh 20 Apr 2009 13:31:21 -0000 1.12
+++ gvars3/gv3_implementation.hh 20 Apr 2009 14:59:39 -0000 1.13
@@ -5,7 +5,7 @@
lvalue =rhs;
};
-#ifdef GVARS3_HAVE_TOON
+#if 0 && !defined GVARS3_HAVE_TOON
// Replacement for operator= which doesn't crash for Vector<-1>; specialisation
void inline robust_assignment(TooN::Vector<> &lvalue, TooN::Vector<> rhs)
{
Index: gvars3/gvars3.h
===================================================================
RCS file: /cvsroot/libcvd/gvars3/gvars3/gvars3.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- gvars3/gvars3.h 20 Apr 2009 13:31:21 -0000 1.21
+++ gvars3/gvars3.h 20 Apr 2009 14:59:39 -0000 1.22
@@ -96,10 +96,6 @@
typedef gvar2<double> gvar2_double;
typedef gvar2<int> gvar2_int;
typedef gvar2<std::string> gvar2_string;
-#ifdef GVARS3_HAVE_TOON
-typedef gvar2<TooN::Vector<-1> > gvar2_Vector;
-typedef gvar2<TooN::Matrix<-1> > gvar2_Matrix;
-#endif
template<class T> class gvar3: public gvar2<T>
{
@@ -303,14 +299,6 @@
double& GetDouble(const std::string& name, double
default_val=0.0, int flags=0);
std::string& GetString(const std::string& name, const
std::string& default_val="", int flags=0);
- #ifdef GVARS3_HAVE_TOON
- TooN::Vector<>& GetVector(const std::string& name,
const TooN::Vector<>& default_val=TooN::Vector<>(), int flags=0);
- TooN::Matrix<>& GetMatrix(const std::string& name,
const TooN::Matrix<>& default_val=TooN::Matrix<>(), int flags=0);
- TooN::Vector<>& GetVector(const std::string& name,
const std::string& default_val, int flags=0);
- TooN::Matrix<>& GetMatrix(const std::string& name,
const std::string& default_val, int flags=0);
- #endif
-
-
int& GetInt(const std::string& name, const std::string&
default_val, int flags=0);
double& GetDouble(const std::string& name, const std::string&
default_val, int flags=0);
Index: gvars3/serialize.h
===================================================================
RCS file: /cvsroot/libcvd/gvars3/gvars3/serialize.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- gvars3/serialize.h 20 Apr 2009 14:35:06 -0000 1.11
+++ gvars3/serialize.h 20 Apr 2009 14:59:39 -0000 1.12
@@ -48,6 +48,10 @@
return o.str();
}
+ std::string to_string(const std::string& val);
+
+
+
template<class T> std::istream& from_stream(std::istream& i, T&
result)
{
i >> result;
@@ -164,39 +168,73 @@
return o.str();
}
- template<int N> int from_string(std::string s,
TooN::Vector<N>& m);
+ template<int N, int M> std::string to_string(const
TooN::Matrix<N, M>& m)
+ {
+ std::ostringstream o;
+ o << "[ ";
+ for(int i=0; i<m.num_rows(); i++)
+ {
+ if(i != 0)
+ o << "; ";
- int from_string(std::string s, TooN::Vector<>& m);
- template<int N> int from_string(std::string s,
TooN::Vector<N>& m)
+ for(int j=0; j<m.num_cols(); j++)
{
- TooN::Vector<> t;
- int result = from_string(s, t);
- if( result || t.size() != N )
- return 1;
- m = t;
- return 0;
+ if(j != 0)
+ o << " ";
+ o << m[i][j];
+ }
+ }
+ o << "]";
+ return o.str();
}
- std::string to_string(const std::string& s);
- int from_string(std::string s, std::string& so);
+ template<int N> std::istream& from_stream(std::istream&
i, TooN::Vector<N>& m)
+ {
+ std::vector<double> v;
+ from_stream(i, v);
- std::string to_string(const TooN::Matrix<>& m);
- template<int N, int M> std::string to_string(const
TooN::Matrix<N,M>& m){
- TooN::Matrix<> t = m;
- return to_string(t);
+ if(v.size() != m.size())
+ {
+ i.setstate(std::ios::failbit);
+ return i;
}
- int from_string(std::string s, TooN::Matrix<>& m);
- template<int N, int M> int from_string(std::string s,
TooN::Matrix<N,M>& m)
+ else
{
- TooN::Matrix<> t;
- int result = from_string(s,t);
- if( result || t.num_rows()!= N || t.num_cols()!= M )
- return 1;
- m = t;
- return 0;
+ for(int j=0; j < v.size(); j++)
+ m[j] = v[j];
+ return i;
}
+ }
+
- std::string to_string(const TooN::Vector<>& m);
+ template<int N> std::istream& from_stream(std::istream&
i, TooN::Matrix<N>& m)
+ {
+ std::vector<std::vector<double> > v;
+ from_stream(i, v);
+
+ if(v.size() != m.num_rows())
+ {
+ i.setstate(std::ios::failbit);
+ return i;
+ }
+
+ for(int r=1; r < m.size(); r++)
+ {
+ if(v[r].size() != m.num_cols())
+ {
+ i.setstate(std::ios::failbit);
+ return i;
+ }
+ }
+
+
+ for(int r=0; r < m.num_rows(); r++)
+ for(int c=0; c < m.num_cols(); c++)
+ {
+ m[r][c] = v[r][c];
+ }
+ return i;
+ }
#endif
}
}
Index: src/gvars2.cc
===================================================================
RCS file: /cvsroot/libcvd/gvars3/src/gvars2.cc,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- src/gvars2.cc 20 Apr 2009 13:31:21 -0000 1.8
+++ src/gvars2.cc 20 Apr 2009 14:59:39 -0000 1.9
@@ -64,19 +64,6 @@
return Get<string>(name, default_val, flags);
}
- #ifdef GVARS3_HAVE_TOON
- TooN::Vector<>& GVars2::GetVector(const string& name, const
TooN::Vector<>& default_val, int flags)
- {
- return Get<TooN::Vector<> >(name, default_val, flags);
- }
-
- TooN::Matrix<>& GVars2::GetMatrix(const string& name, const
TooN::Matrix<>& default_val, int flags)
- {
- return Get<TooN::Matrix<> >(name, default_val, flags);
- }
- #endif
-
-
int& GVars2::GetInt(const string& name, const string& default_val, int
flags)
{
@@ -88,20 +75,6 @@
return Get<double>(name, default_val, flags);
}
- #ifdef GVARS3_HAVE_TOON
- TooN::Vector<>& GVars2::GetVector(const string& name, const string&
default_val, int flags)
- {
- return Get<TooN::Vector<> >(name, default_val, flags);
- }
-
- TooN::Matrix<>& GVars2::GetMatrix(const string& name, const string&
default_val, int flags)
- {
- return Get<TooN::Matrix<> >(name, default_val, flags);
- }
- #endif
-
-
-
string GVars2::StringValue(const string &name, bool no_quotes)
{
if(no_quotes)
Index: src/serialize.cc
===================================================================
RCS file: /cvsroot/libcvd/gvars3/src/serialize.cc,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- src/serialize.cc 20 Apr 2009 14:35:06 -0000 1.13
+++ src/serialize.cc 20 Apr 2009 14:59:39 -0000 1.14
@@ -31,7 +31,21 @@
{
std::string to_string(const std::string& s)
{
- return s;
+ ostringstream os;
+ os << "\"";
+
+ for(size_t i=0; i < s.size(); i++)
+ {
+ if(s[i] == '\\')
+ os << "\\\\";
+ else if(s[i] == '\n')
+ os << "\\n";
+ else
+ os << s[i];
+ }
+
+ os << "\"";
+ return os.str();
}
istream& from_stream(istream& in, string& s)
Index: src/serialize_toon.cc
===================================================================
RCS file: src/serialize_toon.cc
diff -N src/serialize_toon.cc
--- src/serialize_toon.cc 20 Apr 2009 12:59:21 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,171 +0,0 @@
-/*
- This file is part of the GVars3 Library.
-
- Copyright (C) 2005 The Authors
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library 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
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
-
-#include "gvars3/serialize.h"
-#include <vector>
-
-using namespace std;
-using namespace TooN;
-
-
-namespace GVars3
-{
-namespace serialize
-{
- string to_string(const Matrix<>& m)
- {
- ostringstream o;
-
- o << "[";
-
- for(int i=0; i < m.num_rows(); i++)
- {
- for(int j=0; j < m.num_cols(); j++)
- o << " " << m[i][j];
- if(i < m.num_rows() - 1)
- o << " ;";
- }
- o << " ]";
- return o.str();
- }
-
-
-
- int from_string(string s, Matrix<>& mat)
- {
- // Format expected is: [ num .. num; ... ; num .. num ]
- string::size_type n;
-
- //First, find opening angle bracket.
- //Trim up to and including this. Abort if it can't be found.
- n=s.find("[");
- if(n==s.npos)
- return 1;
- s.erase(0, n+1 );
-
- // Trim the closing brace and rest of line. Again, abort if
can't be found.
- n=s.find("]");
- if(n==s.npos)
- return 1;
- s.erase(n, s.npos-n );
-
- vector<double> vd; // Store all the numbers in this here.
-
- int nRows=1;
- int nCols;
- string sub;
- double d;
-
- n=s.find(";"); // Read out the first line. Might be the last.
- {
- sub=s.substr(0,n);
- istringstream ist(sub);
- while(ist>>d)
- vd.push_back(d);
- };
-
- nCols=vd.size();
- if(nCols<1)
- return 1;
-
- while(n!=s.npos) // This means that n pointed to a semicolon,
not the end of the string
- { // Ergo: at least another line to go.
- nRows++;
- s.erase(0,n+1);
- n=s.find(";");
- sub=s.substr(0,n);
- istringstream ist(sub);
- while(ist>>d)
- vd.push_back(d);
-
- if(static_cast<int>(vd.size())!=nRows*nCols) // Were
there the right number of elements?
- return 1;
- };
-
- // Now construct and fill the matrix.
- Matrix<> m(nRows, nCols);
-
- for(int i=0;i<nRows;i++)
- for(int j=0;j<nCols;j++)
- m(i,j)=vd[i*nCols+j];
-
- mat.resize(m.num_rows(), m.num_cols());
- mat = m;
-
- return 0;
- }
-
-
- string to_string(const Vector<>& m)
- {
- ostringstream o;
-
- o << "[ ";
- for(int i=0; i<m.size(); i++)
- o << m[i] << " ";
- o << "]";
- return o.str();
- }
-
-
- int from_string(string s, Vector<>& vec)
- {
- // Format expected is: [ num num num .. num ]
- string::size_type n;
-
- //First, find opening angle bracket.
- //Trim up to and including this. Abort if it can't be found.
- n=s.find("[");
- if(n==s.npos)
- return 1;
-
- s.erase(0, n+1 );
- // Trim the closing brace and rest of line. Again, abort if
can't be found.
- n=s.find("]");
- if(n==s.npos)
- return 1;
-
- s.erase(n, s.npos-n );
-
- //Now, we can read some numbers! Turn into a stream, and build
an STL-vector of doubles.
- istringstream ist(s);
- double d;
- vector<double> vd;
-
- while(ist>>d)
- vd.push_back(d);
-
- if(vd.size()<1)// Abort if vector was empty.
- return 1;
-
- // Now transfer the STL-vector over to a TooN - Vector.
- Vector<> v(vd.size());
-
- for(size_t i=0;i<vd.size();i++)
- v[i]=vd[i];
-
- vec.resize(v.size());
- vec = v;
-
- return 0;
- }
-}
-}