Changeset 5029 for branches/uq/src
- Timestamp:
- Feb 17, 2015 5:49:36 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/uq/src/core/RpUnits.cc
r4224 r5029 70 70 exponent = 1; 71 71 72 // check to see if there is an exponent at the end 72 // check to see if there is an exponent at the end 73 73 // of the search string 74 74 idx = RpUnits::grabExponent(searchStr, &exponent); … … 353 353 } 354 354 355 // check to see if they are the same basis, 355 // check to see if they are the same basis, 356 356 // no need to list all of the metric conversions. 357 357 if (basis) { … … 493 493 494 494 // 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 497 497 // deleted, we are not trying to delete already deleted memory. 498 498 // so for the sake of safety we get the following few lines of code. … … 528 528 // this is kinda the wrong way to get the job done... 529 529 // 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, 531 531 // we are not trying to delete already deleted memory. 532 532 // so for the sake of safety we get the following few lines of code. … … 640 640 /// Retrieve the RpUnits object representing the basis of this object. 641 641 /** 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 643 643 * RpUnits object that is the basis of the calling object. 644 644 */ … … 808 808 * across a unit that is unrecognized or can not be interpreted, then it 809 809 * returns error (a non-zero value). 810 * 810 * 811 811 * 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 813 813 * back into the original formula. i still need to work on this. 814 814 */ … … 920 920 921 921 if ((RPUNITS_ORIG_EXP & flags) == RPUNITS_STRICT_NAME) { 922 // if the user asks for strict naming, 922 // if the user asks for strict naming, 923 923 // always place the exponent on the name 924 924 name << myExp; … … 1114 1114 1115 1115 /* 1116 // if the exponent != 1,-1 then do a second search 1116 // if the exponent != 1,-1 then do a second search 1117 1117 // for the unit+exponent string that might be defined. 1118 1118 // this is to cover the case were we have defined conversions … … 1397 1397 // these are conditions where no conversion is needed 1398 1398 if ( (fromUnitsName.empty()) || (toUnitsName == fromUnitsName) ) { 1399 // there were no units in the input 1399 // there were no units in the input 1400 1400 // string or no conversion needed 1401 1401 // assume fromUnitsName = toUnitsName … … 1508 1508 toIter = toUnitsList.begin(); 1509 1509 1510 // raise error that there was an 1510 // raise error that there was an 1511 1511 // unrecognized conversion request 1512 1512 … … 1651 1651 } 1652 1652 1653 return (std::string(unitText.str())); 1653 return (std::string(unitText.str())); 1654 1654 1655 1655 } … … 1701 1701 // trying to avoid the recursive way of converting to the basis. 1702 1702 // need to rethink this. 1703 // 1703 // 1704 1704 if ( (basis) && (basis->getUnitsName() != toUnit->getUnitsName()) ) { 1705 1705 value = convert(basis,value,&my_result); … … 1711 1711 // find the toUnit in our dictionary. 1712 1712 // 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 1714 1714 // original unit. 1715 1715 if ( (toBasis) && (toBasis->getUnitsName() != fromUnit->getUnitsName()) ) { … … 1755 1755 // conversion for a two arg conv function pointer 1756 1756 // need to make this simpler, more logical maybe only allow 2 arg 1757 if ( (p->conv->convForwFxnPtr) 1757 if ( (p->conv->convForwFxnPtr) 1758 1758 && (! p->conv->convForwFxnPtrDD) ) { 1759 1759 1760 1760 value = p->conv->convForwFxnPtr(value); 1761 1761 } 1762 else if ( (p->conv->convForwFxnPtrDD) 1762 else if ( (p->conv->convForwFxnPtrDD) 1763 1763 && (! p->conv->convForwFxnPtr) ) { 1764 1764 1765 value = 1765 value = 1766 1766 p->conv->convForwFxnPtrDD(value, fromUnit->getExponent()); 1767 1767 } … … 1770 1770 // or to the requested unit's basis. 1771 1771 // 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 1773 1773 // to the requested unit. 1774 1774 if ( (toBasis) && (toBasis->getUnitsName() != fromUnit->getUnitsName()) ) { … … 1783 1783 1784 1784 // 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 1787 1787 // conversion object was not properly created... 1788 1788 // ie. both fxn ptrs were null or neither fxn ptr was null … … 1803 1803 // conversion for a two arg conv function pointer 1804 1804 // need to make this simpler, more logical maybe only allow 2 arg 1805 if ( (p->conv->convBackFxnPtr) 1805 if ( (p->conv->convBackFxnPtr) 1806 1806 && (! p->conv->convBackFxnPtrDD) ) { 1807 1807 1808 1808 value = p->conv->convBackFxnPtr(value); 1809 1809 } 1810 else if ( (p->conv->convBackFxnPtrDD) 1810 else if ( (p->conv->convBackFxnPtrDD) 1811 1811 && (! p->conv->convBackFxnPtr) ) { 1812 1812 1813 value = 1813 value = 1814 1814 p->conv->convBackFxnPtrDD(value, fromUnit->getExponent()); 1815 1815 } … … 1818 1818 // or to the requested unit's basis. 1819 1819 // 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 1821 1821 // to the requested unit. 1822 1822 if ( (toBasis) && (toBasis->getUnitsName() != fromUnit->getUnitsName()) ) { … … 1831 1831 1832 1832 // 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 1835 1835 // conversion object was not properly created... 1836 1836 // ie. both fxn ptrs were null or neither fxn ptr was null … … 1911 1911 // find the toUnit in our dictionary. 1912 1912 // 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 1914 1914 // original unit. 1915 1915 if ( (toBasis) && (toBasis->getUnitsName() != fromUnit->getUnitsName()) ) { … … 1955 1955 // or to the requested unit's basis. 1956 1956 // 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 1958 1958 // to the requested unit. 1959 1959 if ( (toBasis) && (toBasis->getUnitsName() != fromUnit->getUnitsName()) ) { … … 1968 1968 1969 1969 // 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 1972 1972 // conversion object was not properly created... 1973 1973 // ie. both fxn ptrs were null or neither fxn ptr was null … … 1988 1988 // or to the requested unit's basis. 1989 1989 // 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 1991 1991 // to the requested unit. 1992 1992 if ( (toBasis) && (toBasis->getUnitsName() != fromUnit->getUnitsName()) ) { … … 2001 2001 2002 2002 // 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 2005 2005 // conversion object was not properly created... 2006 2006 // ie. both fxn ptrs were null or neither fxn ptr was null … … 2084 2084 // find the toUnit in our dictionary. 2085 2085 // 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 2087 2087 // original unit. 2088 2088 if ( (toBasis) && (toBasis->getUnitsName() != fromUnit->getUnitsName()) ) { … … 2148 2148 // or to the requested unit's basis. 2149 2149 // 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 2151 2151 // to the requested unit. 2152 2152 if ( (toBasis) && (toBasis->getUnitsName() != fromUnit->getUnitsName()) ) { … … 2166 2166 // conversion for a two arg conv function pointer 2167 2167 // need to make this simpler, more logical maybe only allow 2 arg 2168 if ( (p->conv->convBackFxnPtr) 2168 if ( (p->conv->convBackFxnPtr) 2169 2169 && (! p->conv->convBackFxnPtrDD) ) { 2170 2170 … … 2184 2184 // or to the requested unit's basis. 2185 2185 // 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 2187 2187 // to the requested unit. 2188 2188 if ( (toBasis) && (toBasis->getUnitsName() != fromUnit->getUnitsName()) ) { … … 2280 2280 /// Place an RpUnits Object into the Rappture Units Dictionary. 2281 2281 /** 2282 * Return whether the inserted key was new with a non-zero 2282 * Return whether the inserted key was new with a non-zero 2283 2283 * value, or if the key already existed with a value of zero. 2284 2284 */ … … 2442 2442 /**********************************************************************/ 2443 2443 // METHOD: addPresetPrefix() 2444 /// 2444 /// 2445 2445 /** 2446 2446 * Defines the following unit prefixes: … … 2543 2543 * days (d) 2544 2544 * 2545 * month and year are not included because simple 2545 * month and year are not included because simple 2546 2546 * day->month conversions may be misleading 2547 2547 * month->year conversions may be included in the future 2548 * 2548 * 2549 2549 * Return codes: 0 success, anything else is error 2550 2550 */ … … 3229 3229 /// Convert a std::list<std::string> into a comma delimited std::string 3230 3230 /** 3231 * Iterates through a std::list<std::string> and returns a comma 3231 * Iterates through a std::list<std::string> and returns a comma 3232 3232 * delimited std::string containing the elements of the inputted std::list. 3233 3233 *
Note: See TracChangeset
for help on using the changeset viewer.