[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 12:59:21 +0000 |
CVSROOT: /cvsroot/libcvd
Module name: gvars3
Changes by: Edward Rosten <edrosten> 09/04/20 12:59:21
Modified files:
. : Makefile.in configure configure.ac
gvars3 : gv3_implementation.hh gvars3.h serialize.h
type_name.h
src : gvars2.cc gvars3.cc serialize.cc
Added files:
gvars3 : config.h.in
src : serialize_toon.cc
Log message:
Make TooN optional.
You'll need to create an empty config.h file for VisualStudio, or a
config.h
with the line #define GVARS3_HAVE_TOON if you want to use TooN
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gvars3/Makefile.in?cvsroot=libcvd&r1=1.27&r2=1.28
http://cvs.savannah.gnu.org/viewcvs/gvars3/configure?cvsroot=libcvd&r1=1.20&r2=1.21
http://cvs.savannah.gnu.org/viewcvs/gvars3/configure.ac?cvsroot=libcvd&r1=1.19&r2=1.20
http://cvs.savannah.gnu.org/viewcvs/gvars3/gvars3/gv3_implementation.hh?cvsroot=libcvd&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/gvars3/gvars3/gvars3.h?cvsroot=libcvd&r1=1.19&r2=1.20
http://cvs.savannah.gnu.org/viewcvs/gvars3/gvars3/serialize.h?cvsroot=libcvd&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/gvars3/gvars3/type_name.h?cvsroot=libcvd&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/gvars3/gvars3/config.h.in?cvsroot=libcvd&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gvars3/src/gvars2.cc?cvsroot=libcvd&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/gvars3/src/gvars3.cc?cvsroot=libcvd&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/gvars3/src/serialize.cc?cvsroot=libcvd&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/gvars3/src/serialize_toon.cc?cvsroot=libcvd&rev=1.1
Patches:
Index: Makefile.in
===================================================================
RCS file: /cvsroot/libcvd/gvars3/Makefile.in,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- Makefile.in 11 Jun 2008 09:33:45 -0000 1.27
+++ Makefile.in 20 Apr 2009 12:59:19 -0000 1.28
@@ -97,7 +97,7 @@
src/serialize.o \
src/@address@hidden \
src/GUI_non_readline.o \
- src/inst.o
+ src/inst.o\
ifeq (@have_readline@,yes)
OBJS+=src/GUI_readline.o
@@ -107,6 +107,11 @@
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.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- configure 18 Feb 2009 17:43:58 -0000 1.20
+++ configure 20 Apr 2009 12:59:20 -0000 1.21
@@ -1278,7 +1278,7 @@
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
- --with-TooN=directory Specify location for TooN
+ --with-TooN
--without-readline Disable use of libreadline
--with-x use the X Window System
--without-headless Do not build additional headless library
@@ -3423,13 +3423,9 @@
echo
echo --------------------------
-echo Checking for prerequisites
+echo Checking for options
echo --------------------------
-###################################################
-#
-#Allow the user to specify the location of TooN
-#
# Check whether --with-TooN was given.
if test "${with_TooN+set}" = set; then
@@ -3437,36 +3433,13 @@
fi
-if test "$opt_toon_dir" = no
-then
- { { echo "$as_me:$LINENO: error: \"TooN is not optional. Use
--with-TooN=dir to specify where it can be found.\"" >&5
-echo "$as_me: error: \"TooN is not optional. Use --with-TooN=dir to specify
where it can be found.\"" >&2;}
- { (exit 1); exit 1; }; }
-fi
-
-#Yes is not a useful answer. We know the answer is yes.
-if test "$opt_toon_dir" = yes
+if test "$opt_toon_dir" != no
then
- opt_toon_dir=
-fi
-
-#Check for TooN
-{ echo "$as_me:$LINENO: checking for TooN" >&5
+ #Check for TooN
+ { echo "$as_me:$LINENO: checking for TooN" >&5
echo $ECHO_N "checking for TooN... $ECHO_C" >&6; }
-#Check for TooN in a bunch of places
-save_CPPFLAGS="$CPPFLAGS"
-toondir="Missing"
-for dir in $opt_toon_dir "" "$HOME/usr/include" "$HOME/code/TooN"
"$HOME/Src/TooN" "../TooN" ".."
-do
a=
- if test "$dir" = ""
- then
- CPPFLAGS="$save_CPPFLAGS"
- else
- CPPFLAGS="$save_CPPFLAGS -I$dir"
- fi
-
cat >conftest.$ac_ext <<_ACEOF
#include <TooN/TooN.h>
int main(){TooN::Vector<2> v;return 0;}
@@ -3498,79 +3471,21 @@
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
- cat >conftest.$ac_ext <<_ACEOF
-#include <numerics.h>
-int main(){Vector<2> 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
- old_toon="$old_toon $dir"
-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
- toondir=$dir
- break
- fi
-done
-
-if test "$toondir" = ""
-then
{ echo "$as_me:$LINENO: result: yes" >&5
echo "${ECHO_T}yes" >&6; }
-else
- { echo "$as_me:$LINENO: result: $toondir" >&5
-echo "${ECHO_T}$toondir" >&6; }
-fi
-
-if test "$toondir" = Missing
-then
- { echo "$as_me:$LINENO: WARNING: TooN is missing." >&5
-echo "$as_me: WARNING: TooN is missing." >&2;}
- if test "$old_toon" != ""
- then
- { echo "$as_me:$LINENO: WARNING: You have old versions of TooN
installed in $old_toon. These are too old for gvars." >&5
-echo "$as_me: WARNING: You have old versions of TooN installed in $old_toon.
These are too old for gvars." >&2;}
- fi
- toon=no
-else
- options="$options toon"
- toon=yes
cat >>confdefs.h <<\_ACEOF
-#define CVD_HAVE_TOON 1
+#define GVARS3_HAVE_TOON 1
_ACEOF
have_toon=yes
-fi
-
-if test $toon == no
-then
- { { echo "$as_me:$LINENO: error: TooN is required. Visit
savannah.nongnu.org/projects/toon" >&5
-echo "$as_me: error: TooN is required. Visit
savannah.nongnu.org/projects/toon" >&2;}
- { (exit 1); exit 1; }; }
+ options="$options toon"
+ else
+ { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+ fi
fi
@@ -4635,6 +4550,8 @@
+ac_config_headers="$ac_config_headers gvars3/config.h"
+
ac_config_files="$ac_config_files Makefile"
cat >confcache <<\_ACEOF
@@ -4715,37 +4632,7 @@
# Let make expand exec_prefix.
test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
-# Transform confdefs.h into DEFS.
-# Protect against shell expansion while executing Makefile rules.
-# Protect against Makefile macro expansion.
-#
-# If the first sed substitution is executed (which looks for macros that
-# take arguments), then branch to the quote section. Otherwise,
-# look for a macro that doesn't take arguments.
-ac_script='
-t clear
-:clear
-s/^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[
]*\(.*\)/-D\1=\2/g
-t quote
-s/^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[
]*\(.*\)/-D\1=\2/g
-t quote
-b any
-:quote
-s/[ `~#$^&*(){}\\|;'\''"<>?]/\\&/g
-s/\[/\\&/g
-s/\]/\\&/g
-s/\$/$$/g
-H
-:any
-${
- g
- s/^\n//
- s/\n/ /g
- p
-}
-'
-DEFS=`sed -n "$ac_script" confdefs.h`
-
+DEFS=-DHAVE_CONFIG_H
ac_libobjs=
ac_ltlibobjs=
@@ -5080,6 +4967,7 @@
cat >>$CONFIG_STATUS <<_ACEOF
# Files that config.status was made for.
config_files="$ac_config_files"
+config_headers="$ac_config_headers"
_ACEOF
@@ -5097,10 +4985,15 @@
--recheck update $as_me by reconfiguring in the same conditions
--file=FILE[:TEMPLATE]
instantiate the configuration file FILE
+ --header=FILE[:TEMPLATE]
+ instantiate the configuration header FILE
Configuration files:
$config_files
+Configuration headers:
+$config_headers
+
Report bugs to <address@hidden>."
_ACEOF
@@ -5149,7 +5042,16 @@
$ac_shift
CONFIG_FILES="$CONFIG_FILES $ac_optarg"
ac_need_defaults=false;;
- --he | --h | --help | --hel | -h )
+ --header | --heade | --head | --hea )
+ $ac_shift
+ CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg"
+ ac_need_defaults=false;;
+ --he | --h)
+ # Conflict between --help and --header
+ { echo "$as_me: error: ambiguous option: $1
+Try \`$0 --help' for more information." >&2
+ { (exit 1); exit 1; }; };;
+ --help | --hel | -h )
echo "$ac_cs_usage"; exit ;;
-q | -quiet | --quiet | --quie | --qui | --qu | --q \
| -silent | --silent | --silen | --sile | --sil | --si | --s)
@@ -5204,6 +5106,7 @@
for ac_config_target in $ac_config_targets
do
case $ac_config_target in
+ "gvars3/config.h") CONFIG_HEADERS="$CONFIG_HEADERS gvars3/config.h" ;;
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
*) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
@@ -5219,6 +5122,7 @@
# bizarre bug on SunOS 4.1.3.
if $ac_need_defaults; then
test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
+ test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
fi
# Have a temporary directory for convenience. Make it in the build tree
@@ -5392,7 +5296,7 @@
fi # test -n "$CONFIG_FILES"
-for ac_tag in :F $CONFIG_FILES
+for ac_tag in :F $CONFIG_FILES :H $CONFIG_HEADERS
do
case $ac_tag in
:[FHLC]) ac_mode=$ac_tag; continue;;
@@ -5627,7 +5531,104 @@
*) rm -f "$ac_file"; mv "$tmp/out" $ac_file;;
esac
;;
+ :H)
+ #
+ # CONFIG_HEADER
+ #
+_ACEOF
+
+# Transform confdefs.h into a sed script `conftest.defines', that
+# substitutes the proper values into config.h.in to produce config.h.
+rm -f conftest.defines conftest.tail
+# First, append a space to every undef/define line, to ease matching.
+echo 's/$/ /' >conftest.defines
+# Then, protect against being on the right side of a sed subst, or in
+# an unquoted here document, in config.status. If some macros were
+# called several times there might be several #defines for the same
+# symbol, which is useless. But do not sort them, since the last
+# AC_DEFINE must be honored.
+ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*
+# These sed commands are passed to sed as "A NAME B PARAMS C VALUE D", where
+# NAME is the cpp macro being defined, VALUE is the value it is being given.
+# PARAMS is the parameter list in the macro definition--in most cases, it's
+# just an empty string.
+ac_dA='s,^\\([ #]*\\)[^ ]*\\([ ]*'
+ac_dB='\\)[ (].*,\\1define\\2'
+ac_dC=' '
+ac_dD=' ,'
+
+uniq confdefs.h |
+ sed -n '
+ t rset
+ :rset
+ s/^[ ]*#[ ]*define[ ][ ]*//
+ t ok
+ d
+ :ok
+ s/[\\&,]/\\&/g
+ s/^\('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/
'"$ac_dA"'\1'"$ac_dB"'\2'"${ac_dC}"'\3'"$ac_dD"'/p
+ s/^\('"$ac_word_re"'\)[
]*\(.*\)/'"$ac_dA"'\1'"$ac_dB$ac_dC"'\2'"$ac_dD"'/p
+ ' >>conftest.defines
+
+# Remove the space that was appended to ease matching.
+# Then replace #undef with comments. This is necessary, for
+# example, in the case of _POSIX_SOURCE, which is predefined and required
+# on some systems where configure will not decide to define it.
+# (The regexp can be short, since the line contains either #define or #undef.)
+echo 's/ $//
+s,^[ #]*u.*,/* & */,' >>conftest.defines
+
+# Break up conftest.defines:
+ac_max_sed_lines=50
+
+# First sed command is: sed -f defines.sed $ac_file_inputs >"$tmp/out1"
+# Second one is: sed -f defines.sed "$tmp/out1" >"$tmp/out2"
+# Third one will be: sed -f defines.sed "$tmp/out2" >"$tmp/out1"
+# et cetera.
+ac_in='$ac_file_inputs'
+ac_out='"$tmp/out1"'
+ac_nxt='"$tmp/out2"'
+
+while :
+do
+ # Write a here document:
+ cat >>$CONFIG_STATUS <<_ACEOF
+ # First, check the format of the line:
+ cat >"\$tmp/defines.sed" <<\\CEOF
+/^[ ]*#[ ]*undef[ ][ ]*$ac_word_re[ ]*\$/b def
+/^[ ]*#[ ]*define[ ][ ]*$ac_word_re[( ]/b def
+b
+:def
+_ACEOF
+ sed ${ac_max_sed_lines}q conftest.defines >>$CONFIG_STATUS
+ echo 'CEOF
+ sed -f "$tmp/defines.sed"' "$ac_in >$ac_out" >>$CONFIG_STATUS
+ ac_in=$ac_out; ac_out=$ac_nxt; ac_nxt=$ac_in
+ sed 1,${ac_max_sed_lines}d conftest.defines >conftest.tail
+ grep . conftest.tail >/dev/null || break
+ rm -f conftest.defines
+ mv conftest.tail conftest.defines
+done
+rm -f conftest.defines conftest.tail
+echo "ac_result=$ac_in" >>$CONFIG_STATUS
+cat >>$CONFIG_STATUS <<\_ACEOF
+ if test x"$ac_file" != x-; then
+ echo "/* $configure_input */" >"$tmp/config.h"
+ cat "$ac_result" >>"$tmp/config.h"
+ if diff $ac_file "$tmp/config.h" >/dev/null 2>&1; then
+ { echo "$as_me:$LINENO: $ac_file is unchanged" >&5
+echo "$as_me: $ac_file is unchanged" >&6;}
+ else
+ rm -f $ac_file
+ mv "$tmp/config.h" $ac_file
+ fi
+ else
+ echo "/* $configure_input */"
+ cat "$ac_result"
+ fi
+ rm -f "$tmp/out12"
+ ;;
esac
Index: configure.ac
===================================================================
RCS file: /cvsroot/libcvd/gvars3/configure.ac,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- configure.ac 18 Feb 2009 17:43:58 -0000 1.19
+++ configure.ac 20 Apr 2009 12:59:20 -0000 1.20
@@ -77,80 +77,29 @@
echo
echo --------------------------
-echo Checking for prerequisites
+echo Checking for options
echo --------------------------
-###################################################
-#
-#Allow the user to specify the location of TooN
-#
-AC_ARG_WITH(TooN, [ --with-TooN=directory Specify location for TooN ],
[opt_toon_dir=$withval])
-
-if test "$opt_toon_dir" = no
-then
- AC_MSG_ERROR("TooN is not optional. Use --with-TooN=dir to specify
where it can be found.")
-fi
+AC_ARG_WITH(TooN, [ --with-TooN ],
[opt_toon_dir=$withval])
-#Yes is not a useful answer. We know the answer is yes.
-if test "$opt_toon_dir" = yes
+if test "$opt_toon_dir" != no
then
- opt_toon_dir=
-fi
+ #Check for TooN
+ AC_MSG_CHECKING([for TooN])
-#Check for TooN
-AC_MSG_CHECKING([for TooN])
-
-#Check for TooN in a bunch of places
-save_CPPFLAGS="$CPPFLAGS"
-toondir="Missing"
-for dir in $opt_toon_dir "" "$HOME/usr/include" "$HOME/code/TooN"
"$HOME/Src/TooN" "../TooN" ".."
-do
a=
- if test "$dir" = ""
- then
- CPPFLAGS="$save_CPPFLAGS"
- else
- CPPFLAGS="$save_CPPFLAGS -I$dir"
- fi
-
AC_COMPILE_IFELSE([#include <TooN/TooN.h>
int main(){TooN::Vector<2> v;return 0;}], [a=1])
- AC_COMPILE_IFELSE([#include <numerics.h>
-int main(){Vector<2> v;return 0;}], [old_toon="$old_toon $dir"])
-
if test x$a = x1
then
- toondir=$dir
- break
- fi
-done
-
-if test "$toondir" = ""
-then
AC_MSG_RESULT(yes)
-else
- AC_MSG_RESULT($toondir)
-fi
-
-if test "$toondir" = Missing
-then
- AC_MSG_WARN(TooN is missing.)
- if test "$old_toon" != ""
- then
- AC_MSG_WARN(You have old versions of TooN installed in $old_toon. These
are too old for gvars.)
- fi
- toon=no
-else
- options="$options toon"
- toon=yes
- AC_DEFINE(CVD_HAVE_TOON)
+ AC_DEFINE(GVARS3_HAVE_TOON)
AC_SUBST(have_toon,yes)
-fi
-
-if test $toon == no
-then
- AC_MSG_ERROR(TooN is required. Visit savannah.nongnu.org/projects/toon)
+ options="$options toon"
+ else
+ AC_MSG_RESULT(no)
+ fi
fi
TEST_AND_SET_CXXFLAG(-pthread)
@@ -303,4 +252,5 @@
changequote([,])
+AC_CONFIG_HEADERS(gvars3/config.h)
AC_OUTPUT(Makefile)
Index: gvars3/gv3_implementation.hh
===================================================================
RCS file: /cvsroot/libcvd/gvars3/gvars3/gv3_implementation.hh,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- gvars3/gv3_implementation.hh 26 Oct 2007 12:29:24 -0000 1.10
+++ gvars3/gv3_implementation.hh 20 Apr 2009 12:59:20 -0000 1.11
@@ -5,13 +5,15 @@
lvalue =rhs;
};
+#ifdef GVARS3_HAVE_TOON
// Replacement for operator= which doesn't crash for Vector<-1>; specialisation
-void inline robust_assignment(TooN::Vector<> &lvalue, TooN::Vector<> rhs)
+/*void inline robust_assignment(TooN::Vector<> &lvalue, TooN::Vector<> rhs)
{
if(lvalue.size()!=rhs.size())
lvalue.resize(rhs.size());
lvalue = rhs;
-}
+}*/
+#endif
// TODO: Make the specialisation for matrices as well.
Index: gvars3/gvars3.h
===================================================================
RCS file: /cvsroot/libcvd/gvars3/gvars3/gvars3.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- gvars3/gvars3.h 26 Oct 2007 12:29:25 -0000 1.19
+++ gvars3/gvars3.h 20 Apr 2009 12:59:20 -0000 1.20
@@ -28,8 +28,7 @@
#include <vector>
#include <iostream>
-#include <TooN/TooN.h>
-
+#include <gvars3/config.h>
#include <gvars3/type_name.h>
#include <gvars3/serialize.h>
@@ -97,8 +96,10 @@
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>
{
@@ -301,14 +302,14 @@
int& GetInt(const std::string& name, int default_val=0, int
flags=0);
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);
- 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
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);
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);
- 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);
+ //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);
std::string StringValue(const std::string &name, bool
no_quotes=false);
void PrintVarList(std::ostream& os=std::cout);
Index: gvars3/serialize.h
===================================================================
RCS file: /cvsroot/libcvd/gvars3/gvars3/serialize.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- gvars3/serialize.h 27 Jul 2006 15:24:07 -0000 1.9
+++ gvars3/serialize.h 20 Apr 2009 12:59:20 -0000 1.10
@@ -21,10 +21,13 @@
#ifndef GV3_INC_SERIALIZE_H
#define GV3_INC_SERIALIZE_H
-
+#include <gvars3/config.h>
#include <string>
#include <sstream>
-#include <TooN/TooN.h>
+
+#ifdef GVARS3_HAVE_TOON
+ #include <TooN/TooN.h>
+#endif
namespace GVars3
{
@@ -51,7 +54,7 @@
return check_stream(i);
}
-
+ #ifdef GVARS3_HAVE_TOON
template<int N> std::string to_string(const TooN::Vector<N>& m)
{
std::ostringstream o;
@@ -93,7 +96,9 @@
m = t;
return 0;
}
+
std::string to_string(const TooN::Vector<>& m);
+ #endif
}
}
Index: gvars3/type_name.h
===================================================================
RCS file: /cvsroot/libcvd/gvars3/gvars3/type_name.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- gvars3/type_name.h 20 Aug 2008 04:33:23 -0000 1.5
+++ gvars3/type_name.h 20 Apr 2009 12:59:20 -0000 1.6
@@ -23,6 +23,11 @@
#define GV3_INC_TYPE_NAME_H
#include <string>
+#include <gvars3/config.h>
+
+#ifdef GVARS3_HAVE_TOON
+ #include <TooN/TooN.h>
+#endif
namespace GVars3
{
@@ -46,10 +51,12 @@
return "string";
}
+ #ifdef GVARS3_HAVE_TOON
template<> inline std::string type_name<TooN::Vector<> >()
{
return "TooN::Vector<>";
}
+ #endif
template <class T> std::string type_name(const T& t)
{
Index: src/gvars2.cc
===================================================================
RCS file: /cvsroot/libcvd/gvars3/src/gvars2.cc,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- src/gvars2.cc 21 Aug 2008 14:53:27 -0000 1.6
+++ src/gvars2.cc 20 Apr 2009 12:59:20 -0000 1.7
@@ -22,7 +22,6 @@
#include "gvars3/gvars3.h"
using namespace std;
-using namespace TooN;
namespace GVars3
@@ -65,6 +64,7 @@
return Get<string>(name, default_val, flags);
}
+ #ifdef GVARS3_HAVE_TOON
Vector<>& GVars2::GetVector(const string& name, const Vector<>&
default_val, int flags)
{
return Get<Vector<> >(name, default_val, flags);
@@ -74,6 +74,7 @@
{
return Get<Matrix<> >(name, default_val, flags);
}
+ #endif
@@ -87,6 +88,7 @@
return Get<double>(name, default_val, flags);
}
+ #ifdef GVARS3_HAVE_TOON
Vector<>& GVars2::GetVector(const string& name, const string&
default_val, int flags)
{
return Get<Vector<> >(name, default_val, flags);
@@ -96,6 +98,7 @@
{
return Get<Matrix<> >(name, default_val, flags);
}
+ #endif
Index: src/gvars3.cc
===================================================================
RCS file: /cvsroot/libcvd/gvars3/src/gvars3.cc,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- src/gvars3.cc 12 Jun 2008 10:58:44 -0000 1.11
+++ src/gvars3.cc 20 Apr 2009 12:59:20 -0000 1.12
@@ -34,7 +34,6 @@
#endif
using namespace std;
-using namespace TooN;
namespace GVars3
{
Index: src/serialize.cc
===================================================================
RCS file: /cvsroot/libcvd/gvars3/src/serialize.cc,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- src/serialize.cc 21 Aug 2008 14:53:27 -0000 1.10
+++ src/serialize.cc 20 Apr 2009 12:59:20 -0000 1.11
@@ -23,151 +23,12 @@
#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;
- }
-
std::string to_string(const std::string& s)
{
return s;
Index: gvars3/config.h.in
===================================================================
RCS file: gvars3/config.h.in
diff -N gvars3/config.h.in
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gvars3/config.h.in 20 Apr 2009 12:59:20 -0000 1.1
@@ -0,0 +1,4 @@
+#ifndef GVARS3_INCLUDE_CONFIG_H
+#define GVARS3_INCLUDE_CONFIG_H
+#undef GVARS3_HAVE_TOON
+#endif
Index: src/serialize_toon.cc
===================================================================
RCS file: src/serialize_toon.cc
diff -N src/serialize_toon.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/serialize_toon.cc 20 Apr 2009 12:59:21 -0000 1.1
@@ -0,0 +1,171 @@
+/*
+ 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;
+ }
+}
+}
- [libcvd-members] gvars3 Makefile.in configure configure.ac gvars...,
Edward Rosten <=