TuttleOFX  1
TuttleOFX/libraries/tuttle/src/tuttle/host/ofx/attribute/OfxhParamString.cpp
Go to the documentation of this file.
00001 #include "OfxhParamString.hpp"
00002 
00003 #include <boost/functional/hash.hpp>
00004 #include <boost/filesystem/operations.hpp>
00005 
00006 namespace tuttle {
00007 namespace host {
00008 namespace ofx {
00009 namespace attribute {
00010 
00011 const std::string& OfxhParamString::getStringMode() const
00012 {
00013         return getProperties().getStringProperty( kOfxParamPropStringMode );
00014 }
00015 
00016 void OfxhParamString::getV( va_list arg ) const OFX_EXCEPTION_SPEC
00017 {
00018         const char** value = va_arg( arg, const char** );
00019 
00020         this->getValue( _returnValue ); /// @todo tuttle: "I so don't like this, temp storage should be delegated to the implementation"
00021 
00022         *value = _returnValue.c_str();
00023 }
00024 
00025 /**
00026  * implementation of var args function
00027  */
00028 void OfxhParamString::getV( const OfxTime time, va_list arg ) const OFX_EXCEPTION_SPEC
00029 {
00030         const char** value = va_arg( arg, const char** );
00031 
00032         this->getValueAtTime( time, _returnValue ); // I so don't like this, temp storage should be delegated to the implementation
00033 
00034         *value = _returnValue.c_str();
00035 }
00036 
00037 /**
00038  * implementation of var args function
00039  */
00040 void OfxhParamString::setV( va_list arg, const EChange change ) OFX_EXCEPTION_SPEC
00041 {
00042         char* value = va_arg( arg, char* );
00043 
00044         this->setValue( value, change );
00045 }
00046 
00047 /**
00048  * implementation of var args function
00049  */
00050 void OfxhParamString::setV( const OfxTime time, va_list arg, const EChange change ) OFX_EXCEPTION_SPEC
00051 {
00052         char* value = va_arg( arg, char* );
00053 
00054         this->setValueAtTime( time, value, change );
00055 }
00056 
00057 std::size_t OfxhParamString::getHashAtTime( const OfxTime time ) const
00058 {
00059         std::string value;
00060         getValueAtTime( time, value );
00061         std::size_t seed = boost::hash_value( value );
00062         if( getStringMode() == kOfxParamStringIsFilePath )
00063         {
00064                 if( boost::filesystem::exists(value) )
00065                 {
00066                         boost::hash_combine( seed, boost::filesystem::last_write_time(value) );
00067                 }
00068         }
00069         return seed;
00070 }
00071 
00072 }
00073 }
00074 }
00075 }
00076