Changeset 5029 for branches/uq/src


Ignore:
Timestamp:
Feb 17, 2015 5:49:36 PM (9 years ago)
Author:
mmh
Message:

puq integration snap

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/uq/src/core/RpUnits.cc

    r4224 r5029  
    7070    exponent = 1;
    7171
    72     // check to see if there is an exponent at the end 
     72    // check to see if there is an exponent at the end
    7373    // of the search string
    7474    idx = RpUnits::grabExponent(searchStr, &exponent);
     
    353353            }
    354354
    355             // check to see if they are the same basis, 
     355            // check to see if they are the same basis,
    356356            // no need to list all of the metric conversions.
    357357            if (basis) {
     
    493493
    494494    // this is kinda the wrong way to get the job done...
    495     // how do we only create 1 conversion object and share it between 
    496     // atleast two RpUnits objs so that when the RpUnits objs are 
     495    // how do we only create 1 conversion object and share it between
     496    // atleast two RpUnits objs so that when the RpUnits objs are
    497497    // deleted, we are not trying to delete already deleted memory.
    498498    // so for the sake of safety we get the following few lines of code.
     
    528528    // this is kinda the wrong way to get the job done...
    529529    // how do we only create 1 conversion object and share it between at
    530     // least two RpUnits objs so that when the RpUnits objs are deleted, 
     530    // least two RpUnits objs so that when the RpUnits objs are deleted,
    531531    // we are not trying to delete already deleted memory.
    532532    // so for the sake of safety we get the following few lines of code.
     
    640640/// Retrieve the RpUnits object representing the basis of this object.
    641641/**
    642  * Returns a pointer to a RpUnits object which, on success, points to the 
     642 * Returns a pointer to a RpUnits object which, on success, points to the
    643643 * RpUnits object that is the basis of the calling object.
    644644 */
     
    808808 * across a unit that is unrecognized or can not be interpreted, then it
    809809 * returns error (a non-zero value).
    810  * 
     810 *
    811811 * if &compatList == NULL, no compatible list of units will be generated.
    812  * this function does not do a good job of placing the available units 
     812 * this function does not do a good job of placing the available units
    813813 * back into the original formula. i still need to work on this.
    814814 */
     
    920920
    921921    if ((RPUNITS_ORIG_EXP & flags) == RPUNITS_STRICT_NAME) {
    922         // if the user asks for strict naming, 
     922        // if the user asks for strict naming,
    923923        // always place the exponent on the name
    924924        name << myExp;
     
    11141114
    11151115        /*
    1116         // if the exponent != 1,-1 then do a second search 
     1116        // if the exponent != 1,-1 then do a second search
    11171117        // for the unit+exponent string that might be defined.
    11181118        // this is to cover the case were we have defined conversions
     
    13971397    // these are conditions where no conversion is needed
    13981398    if ( (fromUnitsName.empty()) || (toUnitsName == fromUnitsName) )  {
    1399         // there were no units in the input 
     1399        // there were no units in the input
    14001400        // string or no conversion needed
    14011401        // assume fromUnitsName = toUnitsName
     
    15081508                    toIter = toUnitsList.begin();
    15091509
    1510                     // raise error that there was an 
     1510                    // raise error that there was an
    15111511                    // unrecognized conversion request
    15121512
     
    16511651    }
    16521652
    1653     return (std::string(unitText.str())); 
     1653    return (std::string(unitText.str()));
    16541654
    16551655}
     
    17011701    // trying to avoid the recursive way of converting to the basis.
    17021702    // need to rethink this.
    1703     // 
     1703    //
    17041704    if ( (basis) && (basis->getUnitsName() != toUnit->getUnitsName()) ) {
    17051705        value = convert(basis,value,&my_result);
     
    17111711    // find the toUnit in our dictionary.
    17121712    // if the toUnits has a basis, we need to search for the basis
    1713     // and convert between basis' and then convert again back to the 
     1713    // and convert between basis' and then convert again back to the
    17141714    // original unit.
    17151715    if ( (toBasis) && (toBasis->getUnitsName() != fromUnit->getUnitsName()) ) {
     
    17551755            // conversion for a two arg conv function pointer
    17561756            // need to make this simpler, more logical maybe only allow 2 arg
    1757             if (       (p->conv->convForwFxnPtr) 
     1757            if (       (p->conv->convForwFxnPtr)
    17581758                    && (! p->conv->convForwFxnPtrDD) ) {
    17591759
    17601760                value = p->conv->convForwFxnPtr(value);
    17611761            }
    1762             else if (  (p->conv->convForwFxnPtrDD) 
     1762            else if (  (p->conv->convForwFxnPtrDD)
    17631763                    && (! p->conv->convForwFxnPtr) ) {
    17641764
    1765                 value = 
     1765                value =
    17661766                    p->conv->convForwFxnPtrDD(value, fromUnit->getExponent());
    17671767            }
     
    17701770            // or to the requested unit's basis.
    17711771            // if we converted to the requested unit's basis. we need to
    1772             // do one last conversion from the requested unit's basis back 
     1772            // do one last conversion from the requested unit's basis back
    17731773            // to the requested unit.
    17741774            if ( (toBasis) && (toBasis->getUnitsName() != fromUnit->getUnitsName()) ) {
     
    17831783
    17841784            // change the result code to zero, a conversion was performed
    1785             // (we think)... its ture that it is possible to get to this 
    1786             // point and have skipped the conversion because the 
     1785            // (we think)... its ture that it is possible to get to this
     1786            // point and have skipped the conversion because the
    17871787            // conversion object was not properly created...
    17881788            // ie. both fxn ptrs were null or neither fxn ptr was null
     
    18031803            // conversion for a two arg conv function pointer
    18041804            // need to make this simpler, more logical maybe only allow 2 arg
    1805             if (       (p->conv->convBackFxnPtr) 
     1805            if (       (p->conv->convBackFxnPtr)
    18061806                    && (! p->conv->convBackFxnPtrDD) ) {
    18071807
    18081808                value = p->conv->convBackFxnPtr(value);
    18091809            }
    1810             else if (  (p->conv->convBackFxnPtrDD) 
     1810            else if (  (p->conv->convBackFxnPtrDD)
    18111811                    && (! p->conv->convBackFxnPtr) ) {
    18121812
    1813                 value = 
     1813                value =
    18141814                    p->conv->convBackFxnPtrDD(value, fromUnit->getExponent());
    18151815            }
     
    18181818            // or to the requested unit's basis.
    18191819            // if we converted to the requested unit's basis. we need to
    1820             // do one last conversion from the requested unit's basis back 
     1820            // do one last conversion from the requested unit's basis back
    18211821            // to the requested unit.
    18221822            if ( (toBasis) && (toBasis->getUnitsName() != fromUnit->getUnitsName()) ) {
     
    18311831
    18321832            // change the result code to zero, a conversion was performed
    1833             // (we think)... its ture that it is possible to get to this 
    1834             // point and have skipped the conversion because the 
     1833            // (we think)... its ture that it is possible to get to this
     1834            // point and have skipped the conversion because the
    18351835            // conversion object was not properly created...
    18361836            // ie. both fxn ptrs were null or neither fxn ptr was null
     
    19111911    // find the toUnit in our dictionary.
    19121912    // if the toUnits has a basis, we need to search for the basis
    1913     // and convert between basis' and then convert again back to the 
     1913    // and convert between basis' and then convert again back to the
    19141914    // original unit.
    19151915    if ( (toBasis) && (toBasis->getUnitsName() != fromUnit->getUnitsName()) ) {
     
    19551955            // or to the requested unit's basis.
    19561956            // if we converted to the requested unit's basis. we need to
    1957             // do one last conversion from the requested unit's basis back 
     1957            // do one last conversion from the requested unit's basis back
    19581958            // to the requested unit.
    19591959            if ( (toBasis) && (toBasis->getUnitsName() != fromUnit->getUnitsName()) ) {
     
    19681968
    19691969            // change the result code to zero, a conversion was performed
    1970             // (we think)... its ture that it is possible to get to this 
    1971             // point and have skipped the conversion because the 
     1970            // (we think)... its ture that it is possible to get to this
     1971            // point and have skipped the conversion because the
    19721972            // conversion object was not properly created...
    19731973            // ie. both fxn ptrs were null or neither fxn ptr was null
     
    19881988            // or to the requested unit's basis.
    19891989            // if we converted to the requested unit's basis. we need to
    1990             // do one last conversion from the requested unit's basis back 
     1990            // do one last conversion from the requested unit's basis back
    19911991            // to the requested unit.
    19921992            if ( (toBasis) && (toBasis->getUnitsName() != fromUnit->getUnitsName()) ) {
     
    20012001
    20022002            // change the result code to zero, a conversion was performed
    2003             // (we think)... its ture that it is possible to get to this 
    2004             // point and have skipped the conversion because the 
     2003            // (we think)... its ture that it is possible to get to this
     2004            // point and have skipped the conversion because the
    20052005            // conversion object was not properly created...
    20062006            // ie. both fxn ptrs were null or neither fxn ptr was null
     
    20842084    // find the toUnit in our dictionary.
    20852085    // if the toUnits has a basis, we need to search for the basis
    2086     // and convert between basis' and then convert again back to the 
     2086    // and convert between basis' and then convert again back to the
    20872087    // original unit.
    20882088    if ( (toBasis) && (toBasis->getUnitsName() != fromUnit->getUnitsName()) ) {
     
    21482148            // or to the requested unit's basis.
    21492149            // if we converted to the requested unit's basis. we need to
    2150             // do one last conversion from the requested unit's basis back 
     2150            // do one last conversion from the requested unit's basis back
    21512151            // to the requested unit.
    21522152            if ( (toBasis) && (toBasis->getUnitsName() != fromUnit->getUnitsName()) ) {
     
    21662166            // conversion for a two arg conv function pointer
    21672167            // need to make this simpler, more logical maybe only allow 2 arg
    2168             if (       (p->conv->convBackFxnPtr) 
     2168            if (       (p->conv->convBackFxnPtr)
    21692169                    && (! p->conv->convBackFxnPtrDD) ) {
    21702170
     
    21842184            // or to the requested unit's basis.
    21852185            // if we converted to the requested unit's basis. we need to
    2186             // do one last conversion from the requested unit's basis back 
     2186            // do one last conversion from the requested unit's basis back
    21872187            // to the requested unit.
    21882188            if ( (toBasis) && (toBasis->getUnitsName() != fromUnit->getUnitsName()) ) {
     
    22802280/// Place an RpUnits Object into the Rappture Units Dictionary.
    22812281/**
    2282  * Return whether the inserted key was new with a non-zero 
     2282 * Return whether the inserted key was new with a non-zero
    22832283 * value, or if the key already existed with a value of zero.
    22842284 */
     
    24422442/**********************************************************************/
    24432443// METHOD: addPresetPrefix()
    2444 /// 
     2444///
    24452445/**
    24462446 * Defines the following unit prefixes:
     
    25432543 *   days     (d)
    25442544 *
    2545  *   month and year are not included because simple 
     2545 *   month and year are not included because simple
    25462546 *   day->month conversions may be misleading
    25472547 *   month->year conversions may be included in the future
    2548  * 
     2548 *
    25492549 * Return codes: 0 success, anything else is error
    25502550 */
     
    32293229/// Convert a std::list<std::string> into a comma delimited std::string
    32303230/**
    3231  * Iterates through a std::list<std::string> and returns a comma 
     3231 * Iterates through a std::list<std::string> and returns a comma
    32323232 * delimited std::string containing the elements of the inputted std::list.
    32333233 *
Note: See TracChangeset for help on using the changeset viewer.