ADMB Documentation  11.5.3197
 All Classes Files Functions Variables Typedefs Friends Defines
val.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id$
00003  *
00004  * Author: David Fournier
00005  * Copyright (c) 2008-2012 Regents of the University of California
00006  */
00007 #include <fvar.hpp>
00008 #include <stdio.h>
00009 
00010 void val(const adstring& s, int& v, int& code)
00011 {
00012   int z;
00013   if ( (s.size() > 2) && (s(1,2) == adstring("0x") ))
00014     z = sscanf((const char*)s, "%i", &v);
00015   else
00016     z = sscanf((const char*)s, "%d", &v);
00017 
00018   if (z != 1)
00019     code = 1;
00020   else
00021     code = 0;
00022 }
00023 
00024 int val(const adstring& s)
00025 {
00026   int v;
00027   int code;
00028 
00029   val(s, v, code);
00030 
00031   return v;
00032 }