bool npGetProp(INode *node, const TSTR &prop, Vector3 &value, const Vector3 def) { bool ret = false; if (node) { TSTR tmp; if (node->GetUserPropString(prop, tmp)) { value = def; TCHAR *endp = NULL; value.x = _tcstod(tmp, &endp); if (endp) value.y = _tcstod(endp, &endp); if (endp) value.z = _tcstod(endp, &endp); ret = true; } else { value = def; ret = false; } } else { value = def; ret = false; } return ret; }
static void CalculateSector(const TCHAR *Text, TempAirspaceType &temp_area) { fixed Radius; TCHAR *Stop; GeoPoint TempPoint; static const fixed fixed_75 = fixed(7.5); const Angle BearingStep = Angle::degrees(temp_area.Rotation * fixed(5)); Radius = Units::ToSysUnit(fixed(_tcstod(&Text[2], &Stop)), unNauticalMiles); Angle StartBearing = Angle::degrees(fixed(_tcstod(&Stop[1], &Stop))); Angle EndBearing = Angle::degrees(fixed(_tcstod(&Stop[1], &Stop))); if (EndBearing < StartBearing) EndBearing += Angle::degrees(fixed_360); while ((EndBearing - StartBearing).magnitude_degrees() > fixed_75) { StartBearing = StartBearing.as_bearing(); FindLatitudeLongitude(temp_area.Center, StartBearing, Radius, &TempPoint); temp_area.points.push_back(TempPoint); StartBearing += BearingStep; } FindLatitudeLongitude(temp_area.Center, EndBearing, Radius, &TempPoint); temp_area.points.push_back(TempPoint); }
void CRegisterValueAnalyzerDlg::OnBnClickedAxisautomaticCheck() { CChartAxis* pAxis = GetSelectedAxis(); if ( ((CButton*)GetDlgItem(IDC_AXISAUTOMATIC_CHECK))->GetCheck() == 1) pAxis->SetAutomatic(true); else { TCHAR szBuffer[255]; double MinVal=0, MaxVal=0; m_AxisMinValEdit.GetWindowText(szBuffer,254); // MinVal = _tstof(szBuffer); MinVal = _tcstod(szBuffer, NULL); m_AxisMaxValEdit.GetWindowText(szBuffer,254); // MaxVal = _tstof(szBuffer); MaxVal = _tcstod(szBuffer, NULL); if (MinVal > MaxVal) { MessageBox(_T("MinVal > MaxVal"),_T("Error"),MB_OK); ((CButton*)GetDlgItem(IDC_AXISAUTOMATIC_CHECK))->SetCheck(1); return; } pAxis->SetAutomatic(false); pAxis->SetMinMax(MinVal,MaxVal); } m_ChartCtrl.RefreshCtrl(); }
BOOL CPPageFullscreen::OnApply() { UpdateData(); CAppSettings& s = AfxGetAppSettings(); s.strFullScreenMonitor = m_fullScreenMonitor; s.fLaunchfullscreen = !!m_bLaunchFullscreen; s.fExitFullScreenAtTheEnd = !!m_fExitFullScreenAtTheEnd; s.bHideFullscreenControls = !!m_bHideFullscreenControls; { int n = m_hidePolicy.GetCurSel(); if (n != CB_ERR) { s.eHideFullscreenControlsPolicy = static_cast<CAppSettings::HideFullscreenControlsPolicy>(m_hidePolicy.GetItemData(n)); } else { ASSERT(FALSE); } } if (s.eHideFullscreenControlsPolicy == CAppSettings::HideFullscreenControlsPolicy::SHOW_WHEN_CURSOR_MOVED && m_uHideFullscreenControlsDelay > 0 && m_uHideFullscreenControlsDelay < SANE_TIMEOUT_FOR_SHOW_CONTROLS_ON_MOUSE_MOVE) { m_uHideFullscreenControlsDelay = SANE_TIMEOUT_FOR_SHOW_CONTROLS_ON_MOUSE_MOVE; UpdateData(FALSE); } s.uHideFullscreenControlsDelay = m_uHideFullscreenControlsDelay; s.bHideFullscreenDockedPanels = !!m_bHideFullscreenDockedPanels; s.autoChangeFSMode.bEnabled = !!m_bAutoChangeFSModeEnabled; s.autoChangeFSMode.bApplyDefaultModeAtFSExit = !!m_bAutoChangeFSModeApplyDefModeAtFSExist; s.autoChangeFSMode.bRestoreResAfterProgExit = !!m_bAutoChangeFSModeRestoreResAfterProgExit; s.autoChangeFSMode.uDelay = m_uAutoChangeFullscrResDelay; m_autoChangeFSModes.clear(); for (int nItem = 0, count = m_list.GetItemCount(); nItem < count; nItem++) { double dFRStart, dFRStop; if (nItem == 0) { // Special case for default mode dFRStart = 0.0; dFRStop = 0.0; } else { dFRStart = _tcstod(m_list.GetItemText(nItem, COL_FRAMERATE_START), nullptr); dFRStop = _tcstod(m_list.GetItemText(nItem, COL_FRAMERATE_STOP), nullptr); } m_autoChangeFSModes.emplace_back(!!m_list.GetCheck(nItem), dFRStart, dFRStop, m_displayModes[m_list.GetItemData(nItem)]); } s.autoChangeFSMode.modes = m_autoChangeFSModes; // There is no main frame when the option dialog is displayed stand-alone if (CMainFrame* pMainFrame = AfxGetMainFrame()) { pMainFrame->UpdateControlState(CMainFrame::UPDATE_CONTROLS_VISIBILITY); } return __super::OnApply(); }
static void ParseArcBearings(const TCHAR *buffer, TempAirspaceType &temp_area) { // Determine radius and start/end bearing TCHAR *endptr; temp_area.radius = Units::ToSysUnit(fixed(_tcstod(&buffer[2], &endptr)), Unit::NAUTICAL_MILES); Angle start_bearing = Angle::Degrees(_tcstod(&endptr[1], &endptr)).AsBearing(); Angle end_bearing = Angle::Degrees(_tcstod(&endptr[1], &endptr)).AsBearing(); temp_area.AppendArc(start_bearing, end_bearing); }
bool PolarInfo::ReadString(const TCHAR *line) { PolarInfo polar; // Example: // *LS-3 WinPilot POLAR file: MassDryGross[kg], MaxWaterBallast[liters], Speed1[km/h], Sink1[m/s], Speed2, Sink2, Speed3, Sink3 // 403, 101, 115.03, -0.86, 174.04, -1.76, 212.72, -3.4 if (line[0] == _T('*')) /* a comment */ return false; TCHAR *p; polar.reference_mass = fixed(_tcstod(line, &p)); if (*p != _T(',')) return false; polar.max_ballast = fixed(_tcstod(p + 1, &p)); if (*p != _T(',')) return false; polar.v1 = Units::ToSysUnit(fixed(_tcstod(p + 1, &p)), Unit::KILOMETER_PER_HOUR); if (*p != _T(',')) return false; polar.w1 = fixed(_tcstod(p + 1, &p)); if (*p != _T(',')) return false; polar.v2 = Units::ToSysUnit(fixed(_tcstod(p + 1, &p)), Unit::KILOMETER_PER_HOUR); if (*p != _T(',')) return false; polar.w2 = fixed(_tcstod(p + 1, &p)); if (*p != _T(',')) return false; polar.v3 = Units::ToSysUnit(fixed(_tcstod(p + 1, &p)), Unit::KILOMETER_PER_HOUR); if (*p != _T(',')) return false; polar.w3 = fixed(_tcstod(p + 1, &p)); polar.wing_area = (*p != _T(',')) ? fixed_zero : fixed(_tcstod(p + 1, &p)); polar.v_no = (*p != _T(',')) ? fixed_zero : fixed(_tcstod(p + 1, &p)); *this = polar; return true; }
BOOL CClyEditListCtrl::ValidCheck(int nRow, int nCol, LPCTSTR lpszText) { BOOL bResult=FALSE; COleDateTime time = COleDateTime::GetCurrentTime(); COleVariant vtime(lpszText); //将字符串转换为时间 double temp; int sampleNO; CString strNO; switch (nCol) { case 1: break; case 2: sampleNO = _tcstol(lpszText,NULL,10); sampleNO = sampleNO==0?1:sampleNO; strNO.Format(_T("%d"),sampleNO); _tcscpy((TCHAR*)lpszText,strNO); break; case 3: try { vtime.ChangeType(VT_DATE); time = vtime; } catch (CException* e) { CString strTime = time.Format(_T("%Y-%m-%d %H:%M:%S")); _tcscpy((TCHAR*)lpszText,strTime); } break; case 4: //样品重量 temp = _tcstod(lpszText,NULL); if((temp<100)&&(temp>5)) _stprintf((TCHAR*)lpszText,_T("%2.2f"),temp); else _stprintf((TCHAR*)lpszText,_T("%2.2f"),50.0f); case 5: //水分百分比 temp = _tcstod(lpszText,NULL); if(temp<100) _stprintf((TCHAR*)lpszText,_T("%2.2f"),temp); else _stprintf((TCHAR*)lpszText,_T("%2.2f"),1.2f); break; } return TRUE; }
void CCalCoffDlg::OnBnClickedCalCoff() { //样品编号 int iCount = m_Listctrl.GetItemCount(); CString str; for(int i=0;i<iCount;i++) { str = m_Listctrl.GetItemText(i,3); pTrueStd[i] = _tcstod(str,NULL); } if(iCount>1) { GetALinearRegressionEquation(pStd,pTrueStd,iCount,m_slope,m_intercept,m_R );//斜率 截距 str.Format(_T("斜率:%f"),m_slope); GetDlgItem(IDC_STATIC_SLOPE)->SetWindowText(str); str.Format(_T("截距:%f"),m_intercept); GetDlgItem(IDC_STATIC_INTERCEPT)->SetWindowText(str); str.Format(_T("R=%f"),m_R); GetDlgItem(IDC_STATIC_R)->SetWindowText(str); SetDlgItemText(IDC_STATIC_RESULT,m_R>0.98?_T("合格"):_T("不合格")); GetDlgItem(IDC_SAVE_COFF)->EnableWindow(m_R>0.98?TRUE:FALSE); LinearRegressionEquation(pStd,iCount,m_slope,m_intercept,pCalStd); for(int i=0;i<iCount;i++) { str.Format(_T("%f"),pCalStd[i]); m_Listctrl.SetItemText(i,4,str); } } else { MessageBox(_T("记录必须大于两条"),_T("提示"),MB_OK+MB_ICONWARNING); } }
void CPPageFullscreen::OnListEndEdit(NMHDR* pNMHDR, LRESULT* pResult) { LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR; LV_ITEM* pItem = &pDispInfo->item; *pResult = FALSE; if (!m_list.m_fInPlaceDirty) { return; } if (pItem->iItem < 0) { return; } switch (pItem->iSubItem) { case COL_DISPLAY_MODE: if (pItem->lParam >= 0) { VERIFY(m_list.SetItemData(pItem->iItem, (DWORD_PTR)(int)pItem->lParam)); m_list.SetItemText(pItem->iItem, pItem->iSubItem, pItem->pszText); } break; case COL_FRAMERATE_START: case COL_FRAMERATE_STOP: if (pItem->pszText) { CString str = pItem->pszText; double dFR = std::min(std::max(_tcstod(str, nullptr), 1.0), 125.999); str.Format(_T("%.3f"), dFR); m_list.SetItemText(pItem->iItem, pItem->iSubItem, str); } break; } *pResult = TRUE; SetModified(); }
const TCHAR * DataFieldFloat::SetAsString(const TCHAR *Value) { const TCHAR *res = GetAsString(); SetAsFloat(_tcstod(Value, NULL)); return(res); }
/******************************************************************************* Function Name : dGetPos Input(s) : - Output : double - Double precession value of for the text box Functionality : This method get the current virtual double precession value of of the spin button. Member of : CNumSpinCtrl Friend of : Author(s) : Raja N Date Created : 22.07.2004 Modifications : Raja N on 30.07.2004. Code review changes and Int 64 version implementation to support signals > 52 bits length *******************************************************************************/ double CNumSpinCtrl::dGetPos() { // Get the text control first to get the value CWnd* pomEdit = GetBuddy(); char* pDummy = NULL; double dVal = 0.0; // If the buddy is set then proceed if (pomEdit) { CString omStrText; // Get the text pomEdit->GetWindowText (omStrText); // Check for Base value if( GetBase() == defBASE_DEC ) { // In decimal mode floating point values are possible so // Use Double Value function to get decimal points also dVal = _tcstod( omStrText, &pDummy); } else { // Double type should not be used for Hex values ASSERT ( FALSE ); } } // Return calculated value return dVal; }
/** * Converts a String into a Float and returns * the default value if String = NULL * @param String The String to parse * @param Default The default return value * @return The parsed Float value */ static double StringToFloatDflt(const TCHAR *string, double _default) { if (string == NULL || StringIsEmpty(string)) return _default; return _tcstod(string, NULL); }
BOOL CWordPadApp::ParseMeasurement(LPTSTR buf, int& lVal) { TCHAR* pch; if (buf[0] == NULL) return FALSE; float f = (float)_tcstod(buf,&pch); // eat white space, if any while (isspace(*pch)) pch++; if (pch[0] == NULL) // default { lVal = (f < 0.f) ? (int)(f*GetTPU()-0.5f) : (int)(f*GetTPU()+0.5f); return TRUE; } for (int i=0;i<m_nNumUnits;i++) { if (lstrcmpi(pch, GetAbbrev(i)) == 0) { lVal = (f < 0.f) ? (int)(f*GetTPU(i)-0.5f) : (int)(f*GetTPU(i)+0.5f); return TRUE; } } return FALSE; }
// eventAutoZoom - Turn on|off|toggle AutoZoom // misc: // auto on - Turn on if not already // auto off - Turn off if not already // auto toggle - Toggle current full screen status // auto show - Shows autozoom status // + - Zoom in // ++ - Zoom in near // - - Zoom out // -- - Zoom out far // n.n - Zoom to a set scale // show - Show current zoom scale void InputEvents::eventZoom(const TCHAR* misc) { // JMW pass through to handler in MapWindow // here: // -1 means toggle // 0 means off // 1 means on MapSettings &settings_map = CommonInterface::SetMapSettings(); if (StringIsEqual(misc, _T("auto toggle"))) sub_AutoZoom(-1); else if (StringIsEqual(misc, _T("auto on"))) sub_AutoZoom(1); else if (StringIsEqual(misc, _T("auto off"))) sub_AutoZoom(0); else if (StringIsEqual(misc, _T("auto show"))) { if (settings_map.auto_zoom_enabled) Message::AddMessage(_("Auto. zoom on")); else Message::AddMessage(_("Auto. zoom off")); } else if (StringIsEqual(misc, _T("slowout"))) sub_ScaleZoom(-1); else if (StringIsEqual(misc, _T("slowin"))) sub_ScaleZoom(1); else if (StringIsEqual(misc, _T("out"))) sub_ScaleZoom(-1); else if (StringIsEqual(misc, _T("in"))) sub_ScaleZoom(1); else if (StringIsEqual(misc, _T("-"))) sub_ScaleZoom(-1); else if (StringIsEqual(misc, _T("+"))) sub_ScaleZoom(1); else if (StringIsEqual(misc, _T("--"))) sub_ScaleZoom(-2); else if (StringIsEqual(misc, _T("++"))) sub_ScaleZoom(2); else if (StringIsEqual(misc, _T("circlezoom toggle"))) { settings_map.circle_zoom_enabled = !settings_map.circle_zoom_enabled; } else if (StringIsEqual(misc, _T("circlezoom on"))) { settings_map.circle_zoom_enabled = true; } else if (StringIsEqual(misc, _T("circlezoom off"))) { settings_map.circle_zoom_enabled = false; } else if (StringIsEqual(misc, _T("circlezoom show"))) { if (settings_map.circle_zoom_enabled) Message::AddMessage(_("Circling zoom on")); else Message::AddMessage(_("Circling zoom off")); } else { TCHAR *endptr; double zoom = _tcstod(misc, &endptr); if (endptr == misc) return; sub_SetZoom(Units::ToSysDistance(fixed(zoom))); } XCSoarInterface::SendMapSettings(true); }
bool GetDlgItemReal(HWND hWnd, int ItemID, float& Real) { TCHAR pEditStr[256] = {}; if (!GetDlgItemText(hWnd, ItemID, pEditStr, ARRAYSIZE(pEditStr) - 1)) return false; Real = static_cast<float>(_tcstod(pEditStr, nullptr)); return true; }
bool GetDlgItemReal(HWND hWnd, int ItemID, double& Real) { TCHAR pEditStr[256] = {}; if (!GetDlgItemText(hWnd, ItemID, pEditStr, ARRAYSIZE(pEditStr) - 1)) return false; Real = _tcstod(pEditStr, nullptr); return true; }
ULONG CSearchParamsWnd::GetSearchAttrLength(const CString& rstrExpr) { CString strExpr(rstrExpr); strExpr.Trim(); UINT hour = 0, min = 0, sec = 0; if (_stscanf(strExpr, _T("%u : %u : %u"), &hour, &min, &sec) == 3) return hour * 3600 + min * 60 + sec; if (_stscanf(strExpr, _T("%u : %u"), &min, &sec) == 2) return min * 60 + sec; LPTSTR endptr = NULL; double dbl = _tcstod(strExpr, &endptr); if (endptr && *endptr != _T('\0')) { while (*endptr == _T(' ')) endptr++; TCHAR chModifier = _totlower((_TUCHAR)*endptr); if (chModifier == _T('\0') || chModifier == _T('s')) ; else if (chModifier == _T('m')) return (ULONG)(dbl*60 + 0.5); else if (chModifier == _T('h')) return (ULONG)(dbl*60*60 + 0.5); else return (ULONG)-1; } return (ULONG)(dbl + 0.5); }
ULONG CSearchParamsWnd::GetSearchAttrNumber(const CString& rstrExpr) { CString strExpr(rstrExpr); strExpr.Trim(); LPTSTR endptr = NULL; double dbl = _tcstod(strExpr, &endptr); if (endptr && *endptr != _T('\0')) { while (*endptr == _T(' ')) endptr++; TCHAR chModifier = _totlower((_TUCHAR)*endptr); if (chModifier == _T('\0')) ; else if (chModifier == _T('k')) return (ULONG)(dbl*1000 + 0.5); else if (chModifier == _T('m')) return (ULONG)(dbl*1000*1000 + 0.5); else if (chModifier == _T('g')) return (ULONG)(dbl*1000*1000*1000 + 0.5); else return (ULONG)-1; } return (ULONG)(dbl + 0.5); }
uint64 CSearchParamsWnd::GetSearchAttrSize(const CString& rstrExpr) { CString strExpr(rstrExpr); strExpr.Trim(); LPTSTR endptr = NULL; double dbl = _tcstod(strExpr, &endptr); if (endptr && *endptr != _T('\0')) { while (*endptr == _T(' ')) endptr++; TCHAR chModifier = _totlower((_TUCHAR)*endptr); if (chModifier == _T('b')) return (uint64)(dbl + 0.5); else if (chModifier == _T('k')) return (uint64)(dbl*1024 + 0.5); else if (chModifier == _T('\0') || chModifier == _T('m')) ; else if (chModifier == _T('g')) return (uint64)(dbl*1024*1024*1024 + 0.5); else return (uint64)-1; } return (uint64)(dbl*1024*1024 + 0.5); // Default = MBytes }
void CBorderStyleEdit::OnSetfocus() { m_bNowEditing = TRUE; m_bModified = FALSE; CString strValue; GetWindowText( strValue ); if( m_bTextStyle ) { m_strOldValue = strValue; } else { if( strValue.IsEmpty() ) { if( m_bFloatStyle ) { SetWindowText( _T("0.0") ); strValue = _T("0.0"); } else { SetWindowText( _T("0") ); strValue = _T("0"); } } m_dOldValue = _tcstod( strValue, NULL ); } RedrawWindow(); }
void CDlgCalcDlg::OnDigit(UINT nID) { TCHAR cDigit = (char) nID; if (m_bFixPending) { m_strFormat.SetAt (3, cDigit - IDC_0 + 0x30); DisplayXRegister (); m_bFixPending = FALSE; m_bStackLiftEnabled = TRUE; m_bNewX = TRUE; return; } if (m_bNewX) { m_bNewX = FALSE; if (m_bStackLiftEnabled) { m_bStackLiftEnabled = FALSE; LiftStack (); } m_bDecimalInString = FALSE; m_strDisplay.Empty (); } int nLength = m_strDisplay.GetLength (); if ((nLength == MAXCHARS) || ((nLength == (MAXCHARS - 10)) && !m_bDecimalInString)) ::MessageBeep (MB_ICONASTERISK); else { m_strDisplay += (cDigit - IDC_0 + 0x30); UpdateDisplay (m_strDisplay); m_dblStack[0] = _tcstod (m_strDisplay.GetBuffer (0), NULL); } }
static bool ParseAltitude(const TCHAR *input, double *altitude_r, TCHAR **endptr_r) { TCHAR *endptr; double altitude; altitude = _tcstod(input, &endptr); if (endptr == input) return false; switch (*endptr) { case 'M': // meter's nothing to do case 'm': ++endptr; break; case 'F': // feet, convert to meter case 'f': altitude /= TOFEET; ++endptr; break; } *altitude_r = altitude; *endptr_r = endptr; return true; }
/** * Converts a String into a Float and returns * the default value if String = NULL * @param String The String to parse * @param Default The default return value * @return The parsed Float value */ static double StringToFloatDflt(const TCHAR *String, double Default) { if (String == NULL || string_is_empty(String)) return Default; return _tcstod(String, NULL); }
int CSizeComboBox::GetTwipSize() { // return values // -2 -- error // -1 -- edit box empty // >=0 -- font size in twips CString str; GetTheText(str); LPCTSTR lpszText = str; while (*lpszText == ' ' || *lpszText == '\t') lpszText++; if (lpszText[0] == NULL) return -1; // no text in control double d = _tcstod(lpszText, (LPTSTR*)&lpszText); while (*lpszText == ' ' || *lpszText == '\t') lpszText++; if (*lpszText != NULL) return -2; // not terminated properly return (d<0.) ? 0 : (int)(d*20.); }
bool CNumericEdit::IsNumberLPC(LPCTSTR lpszText) { /// From DLGFLOAT.CPP, function _AfxSimpleFloatParse ASSERT(lpszText != NULL); while (*lpszText == ' ' || *lpszText == '\t') lpszText++; /*LPCTSTR signCheck = lpszText; while (*signCheck == '+' || *signCheck == '-') signCheck++; if ((signCheck - lpszText) > 1) return false; if ((signCheck - lpszText) == 1) return true;*/ TCHAR chFirst = lpszText[0]; double d = _tcstod(lpszText, (LPTSTR*)&lpszText); if (d == 0.0 && chFirst != '0') return false; // could not convert /*while (*lpszText == ' ' || *lpszText == '\t') lpszText++;*/ if (*lpszText != '\0') return false; // not terminated properly return true; }
void XShapeLabel::renderSpecial(Canvas &canvas, LabelBlock &label_block, int x, int y) { if (label) { TCHAR Temp[100]; _stprintf(Temp,TEXT("%S"),label); canvas.background_transparent(); // TODO code: JMW asks, what does this do? if (ispunct(Temp[0])) { double dTemp; Temp[0]='0'; dTemp = _tcstod(Temp, NULL); dTemp = ALTITUDEMODIFY*dTemp; if (dTemp > 999) _stprintf(Temp,TEXT("%.1f"),(dTemp/1000)); else _stprintf(Temp,TEXT("%d"),int(dTemp)); } SIZE tsize = canvas.text_size(Temp); RECT brect; x+= 2; y+= 2; brect.left = x; brect.right = brect.left+tsize.cx; brect.top = y; brect.bottom = brect.top+tsize.cy; if (!label_block.check(brect)) return; canvas.set_text_color(Color(0x20,0x20,0x20)); canvas.text(x, y, Temp); } }
static bool ParseAngle(const TCHAR *&src, Angle &angle) { // 41.234234N TCHAR *endptr; // Parse numerical value double value = _tcstod(src, &endptr); if (endptr == src) return false; src = endptr; angle = Angle::Degrees(value); // Skip until next whitespace and look for NSEW signs bool found = false; while (*src != _T(' ') && *src != _T('\0')) { if (!found) { if (*src == _T('N') || *src == _T('n') || *src == _T('E') || *src == _T('e')) { found = true; } else if (*src == _T('S') || *src == _T('s') || *src == _T('W') || *src == _T('w')) { found = true; angle.Flip(); } } src++; } return found; }
// Same, for doubles // bool XML_PARSER::parse_double(const wxChar* start_tag, double& x) { wxChar buf[256], *end; bool eof; wxChar end_tag[256], tag[256]; if (_tcscmp(parsed_tag, start_tag)) return false; end_tag[0] = wxT('/'); _tcscpy(end_tag+1, start_tag); eof = get(buf, sizeof(buf), is_tag); if (eof) return false; if (is_tag) { if (!_tcscmp(buf, end_tag)) { x = 0; // treat <foo></foo> as <foo>0</foo> return true; } else { return false; } } errno = 0; double val = _tcstod(buf, &end); if (errno) return false; if (end != buf+_tcslen(buf)) return false; eof = get(tag, sizeof(tag), is_tag); if (eof) return false; if (!is_tag) return false; if (_tcscmp(tag, end_tag)) return false; x = val; return true; }
BOOL CUtils::StrToDouble (const CString & strValue, double &dValue) { extern int errno; PTCHAR pEnd; errno = 0; dValue = _tcstod (strValue, &pEnd); return (0 == errno) && (*pEnd == _TCHAR('\0')); }
double CXmlConfig::GetAttributeDouble(const TCHAR* attributeName,double defValue,bool* pResult){ bool bRet=false; CString strDefaultValve; strDefaultValve.Format(_T("%f"),defValue); _tstring textValue=GetAttributeValue(attributeName,strDefaultValve,&bRet); if(pResult) (*pResult)=bRet; return bRet?_tcstod(textValue.c_str(),NULL):defValue; }