From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- .../nel/type__unit__int__unsigned_8cpp-source.html | 273 +++++++++++++++++++++ 1 file changed, 273 insertions(+) create mode 100644 docs/doxygen/nel/type__unit__int__unsigned_8cpp-source.html (limited to 'docs/doxygen/nel/type__unit__int__unsigned_8cpp-source.html') diff --git a/docs/doxygen/nel/type__unit__int__unsigned_8cpp-source.html b/docs/doxygen/nel/type__unit__int__unsigned_8cpp-source.html new file mode 100644 index 00000000..380aa1ef --- /dev/null +++ b/docs/doxygen/nel/type__unit__int__unsigned_8cpp-source.html @@ -0,0 +1,273 @@ + + + + nevrax.org : docs + + + + + + + + + + + + + + +
# Home   # nevrax.com   
+ + + + +
Nevrax
+ + + + + + + + + + +
+ + +
+ Nevrax.org
+ + + + + + + +
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
+
+ + +
+ + +
+Docs + +
+  + + + + + +
Documentation 
+ +
+Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  
+

type_unit_int_unsigned.cpp

Go to the documentation of this file.
00001 
+00007 /* Copyright, 2000 Nevrax Ltd.
+00008  *
+00009  * This file is part of NEVRAX NEL.
+00010  * NEVRAX NEL is free software; you can redistribute it and/or modify
+00011  * it under the terms of the GNU General Public License as published by
+00012  * the Free Software Foundation; either version 2, or (at your option)
+00013  * any later version.
+00014 
+00015  * NEVRAX NEL is distributed in the hope that it will be useful, but
+00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
+00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+00018  * General Public License for more details.
+00019 
+00020  * You should have received a copy of the GNU General Public License
+00021  * along with NEVRAX NEL; see the file COPYING. If not, write to the
+00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+00023  * MA 02111-1307, USA.
+00024  */
+00025 
+00026 #include "stdgeorges.h"
+00027 #include "nel/georges/type_unit_int_unsigned.h"
+00028 #include "nel/misc/common.h"
+00029 
+00030 using namespace NLMISC;
+00031 
+00032 
+00033 namespace NLGEORGES
+00034 {
+00035 
+00037 // Construction/Destruction
+00039 
+00040 CTypeUnitIntUnsigned::CTypeUnitIntUnsigned( const CStringEx _sxll, const CStringEx _sxhl, const CStringEx _sxdv, const CStringEx _sxf ) : CTypeUnit( _sxll, _sxhl, _sxdv, _sxf )
+00041 {
+00042         ilowlimit = atoiInt64( sxlowlimit.c_str() ); 
+00043         ihighlimit = atoiInt64( sxhighlimit.c_str() ); 
+00044         idefaultvalue = atoiInt64( sxdefaultvalue.c_str() ); 
+00045         if( sxformula.empty() )
+00046                 sxformula = CStringEx( "uint(" +_sxll +"," +_sxhl +")" );
+00047 }
+00048 
+00049 CTypeUnitIntUnsigned::~CTypeUnitIntUnsigned()
+00050 {
+00051 }
+00052 
+00053 /*
+00054 CStringEx CTypeUnitIntUnsigned::Format( const CStringEx _sxvalue ) const
+00055 {
+00056         if( _sxvalue.empty() )
+00057                 return( sxdefaultvalue );
+00058 
+00059         unsigned __int64 ivalue = _atoi64( _sxvalue.c_str() );
+00060         if( ivalue < ilowlimit )
+00061                 ivalue = ilowlimit;
+00062         if( ivalue > ihighlimit )
+00063                 ivalue = ihighlimit;
+00064 
+00065         char pc[256];
+00066         _ui64toa( ivalue, pc, 10 );
+00067         return( CStringEx( pc ) );
+00068 }
+00069 */
+00070 
+00071 CStringEx CTypeUnitIntUnsigned::Format( const CStringEx _sxvalue ) const
+00072 {
+00073         if( _sxvalue.empty() )
+00074                 return( sxdefaultvalue );
+00075 
+00076         std::vector< std::pair< CStringEx, CStringEx > > modificationValues;
+00077         CStringEx value( _sxvalue );
+00078         value.purge();
+00079         while( value[0] == '<' )
+00080         {
+00081                 unsigned int pos = value.find( '>' );
+00082                 if( pos == -1 )
+00083                         break;
+00084                 CStringEx sxoperateur = value.get_mid( 1, 1 );
+00085                 CStringEx sxoperande = value.get_mid( 2, pos-2);
+00086                 value.right( value.size()-pos-1 );
+00087                 modificationValues.push_back( std::make_pair( sxoperateur, sxoperande ) );
+00088         }
+00089         if( modificationValues.size() )
+00090         {
+00091                 CStringEx sxr;
+00092                 for( std::vector< std::pair< CStringEx, CStringEx > >::iterator it = modificationValues.begin(); it != modificationValues.end(); ++it )
+00093                 {
+00094                         sxr += CStringEx( "<" );
+00095                         sxr += it->first;
+00096                         sxr += it->second;
+00097                         sxr += CStringEx( ">" );
+00098                 }
+00099                 return( sxr );
+00100         }
+00101         else
+00102         {
+00103                 uint64 ivalue = atoiInt64( _sxvalue.c_str() );
+00104                 if( ivalue < ilowlimit )
+00105                         ivalue = ilowlimit;
+00106                 if( ivalue > ihighlimit )
+00107                         ivalue = ihighlimit;
+00108 
+00109                 char pc[256];
+00110                 itoaInt64( ivalue, pc, 10 );
+00111                 return( CStringEx( pc ) );
+00112         }
+00113 }
+00114 
+00115 /*                                                                      
+00116 CStringEx CTypeUnitIntUnsigned::CalculateResult( const CStringEx _sxbasevalue, const CStringEx _sxvalue ) const 
+00117 {
+00118         nlassert( !_sxbasevalue.empty() );
+00119         if( _sxvalue.empty() )
+00120                 return( _sxbasevalue );
+00121         return( Format( _sxvalue ) );
+00122 }
+00123 */
+00124 
+00125 CStringEx CTypeUnitIntUnsigned::CalculateResult( const CStringEx _sxbasevalue, const CStringEx _sxvalue ) const 
+00126 {
+00127         nlassert( !_sxbasevalue.empty() );
+00128         if( _sxvalue.empty() )
+00129                 return( _sxbasevalue );
+00130 
+00131         std::vector< std::pair< CStringEx, CStringEx > > modificationValues;
+00132         CStringEx value( _sxvalue );
+00133         value.purge();
+00134         while( value[0] == '<' )
+00135         {
+00136                 unsigned int pos = value.find( '>' );
+00137                 if( pos == -1 )
+00138                         break;
+00139                 CStringEx sxoperateur = value.get_mid( 1, 1 );
+00140                 CStringEx sxoperande = value.get_mid( 2, pos-2);
+00141                 value.right( value.size()-pos-1 );
+00142                 modificationValues.push_back( std::make_pair( sxoperateur, sxoperande ) );
+00143         }
+00144         if( modificationValues.size() )
+00145         {
+00146                 sint64 ir = atoiInt64( _sxbasevalue.c_str() );
+00147                 for( std::vector< std::pair< CStringEx, CStringEx > >::iterator it = modificationValues.begin(); it != modificationValues.end(); ++it )
+00148                 {
+00149                         sint64 ivalue = atoiInt64( it->second.c_str() );
+00150                         if( it->first == "+" )
+00151                                 ir += ivalue;
+00152                         else if( it->first == "*" )
+00153                                         ir *= ivalue;
+00154                                 else if( it->first == "-" )
+00155                                                 ir -= ivalue;
+00156                                         else if( it->first == "/" )
+00157                                                         ir /= ivalue;   
+00158                                                 else if( it->first == "^" )
+00159                                                 {
+00160                                                         ir = (sint64)( pow( (double)(ir), (double)(ivalue) ) );   
+00161                                                 }
+00162                 }
+00163                 uint64 uir = ir;
+00164                 if( uir < ilowlimit )
+00165                         uir = ilowlimit;
+00166                 if( uir > ihighlimit )
+00167                         uir = ihighlimit;
+00168                 char pc[256];
+00169                 itoaInt64( uir, pc, 10 );
+00170                 return( CStringEx( pc ) );
+00171         }
+00172         else
+00173         {
+00174                 uint64 ivalue = atoiInt64( _sxvalue.c_str() );
+00175                 if( ivalue < ilowlimit )
+00176                         ivalue = ilowlimit;
+00177                 if( ivalue > ihighlimit )
+00178                         ivalue = ihighlimit;
+00179                 char pc[256];
+00180                 itoaInt64( ivalue, pc, 10 );
+00181                 return( CStringEx( pc ) );
+00182         }
+00183         return( Format( _sxvalue ) );
+00184 }
+00185 
+00186 void CTypeUnitIntUnsigned::SetDefaultValue( const CStringEx _sxdv )
+00187 {
+00188         sxdefaultvalue = _sxdv;
+00189         idefaultvalue = atoiInt64( sxdefaultvalue.c_str() ); 
+00190 }
+00191 
+00192 void CTypeUnitIntUnsigned::SetLowLimit( const CStringEx _sxll )
+00193 {
+00194         sxlowlimit = _sxll;
+00195         ilowlimit = atoiInt64( sxlowlimit.c_str() ); 
+00196 }
+00197 
+00198 void CTypeUnitIntUnsigned::SetHighLimit( const CStringEx _sxhl )
+00199 {
+00200         sxhighlimit = _sxhl;
+00201         ihighlimit = atoiInt64( sxhighlimit.c_str() ); 
+00202 }
+00203 
+00204 }
+00205 
+00206 
+
+ + +
                                                                                                                                                                    +
+ + -- cgit v1.2.1