/home/coin/SVN-release/CoinAll-1.1.0/Ipopt/contrib/MatlabInterface/src/matlaboption.h

Go to the documentation of this file.
00001 // Copyright (C) 2007 Peter Carbonetto. All Rights Reserved.
00002 // This code is published under the Common Public License.
00003 //
00004 // Author: Peter Carbonetto
00005 //         Dept. of Computer Science
00006 //         University of British Columbia
00007 //         May 19, 2007
00008 
00009 #ifndef INCLUDE_MATLABOPTION
00010 #define INCLUDE_MATLABOPTION
00011 
00012 #include "mex.h"
00013 #include <string>
00014 
00015 // Class MatlabOption.
00016 // -----------------------------------------------------------------
00017 class MatlabOption {
00018 public:
00019 
00020   // This constructor creates an object starting from a Matlab
00021   // array. The Matlab array must either be a string or a scalar in
00022   // double precision.
00023   MatlabOption (const mxArray* ptr);
00024 
00025   // Return "true" if the option value is a string.
00026   bool isString() const { return s; };
00027 
00028   // Get the option value.
00029   operator const char*        () const { return s->c_str(); };
00030   operator const std::string& () const { return *s;         };
00031   operator double             () const { return x;          };
00032   operator int                () const { return (int) x;    };
00033 
00034   // The destructor.
00035   ~MatlabOption();
00036 
00037 protected:
00038   std::string* s;  // The string value.
00039   double       x;  // The double value.
00040 };
00041 
00042 #endif

Generated on Sun Nov 14 14:06:33 2010 for Coin-All by  doxygen 1.4.7