UINT WebFeedContentElement::GetApproximateSaveSize() { UINT size = 32; if (HasValue()) if (IsBinary()) size += (UINT)(m_value_length * 0.75); else // content is saved in UTF-8. With mostly western characters // it will probably use less space than this, with others probably more size += (UINT)(m_value_length * 0.75); return size; }
void Token::ThrowIfInproperInit() throw(TokenException) { switch(m_type) { case PrimativeToken::Number: case PrimativeToken::Identifier: if (!HasValue()) { throw TokenException(); } break; case PrimativeToken::StringLit: // Strings can be empty return; default: if (HasValue()) { throw TokenException(); } break; } }
void WebFeedContentElement::WriteAsStrippedHTMLL(URL& out_url) const { if (!HasValue()) return; if (!IsMarkup()) // no markup to strip { WriteAsHTMLL(out_url); return; } OpString stripped; ANCHOR(OpString, stripped); LEAVE_IF_ERROR(WebFeedUtil::StripTags((uni_char*)m_value, stripped)); LEAVE_IF_ERROR(out_url.WriteDocumentData(URL::KNormal, stripped)); }
void WebFeedContentElement::WriteAsHTMLL(URL& out_url) const { if (HasValue()) { if (IsPlainText()) LEAVE_IF_ERROR(out_url.WriteDocumentData(URL::KHTMLify, (uni_char*)m_value, m_value_length / sizeof(uni_char))); else if (IsMarkup()) { OpString stripped_html; ANCHOR(OpString, stripped_html); WebFeedUtil::StripTags((const uni_char*)m_value, stripped_html, UNI_L("style"), TRUE); LEAVE_IF_ERROR(out_url.WriteDocumentData(URL::KNormal, stripped_html, stripped_html.Length())); } else OP_ASSERT(!"What to do, what to do, with this strange content type"); } }
QString ServerConnector::getState(const QString& path) { Q_ASSERT( m_initialized); std::string pwpath = path.toStdString(); auto pwval = m_stateManager->XmlStateManager().GetValue( pwpath); if( !pwval.HasValue()) { return QString(); } // warning: this is NOT how to convert CSI::string to std::string as it will use // the stream operator, which will treat spaces as separators... ie. you won't // be able to receive values with spaces in them ;( // std::string val = pwval.ValueOr( "").As<std::string>(); // this is how to convert to std::string: QString val( pwval.ValueOr( "").ToAscii().begin()); return val; }
OP_STATUS OpNumberEdit::GetText(OpString &str) { double val; if (HasValue() && GetValue(val)) { OP_STATUS status; uni_char* value_buf = str.Reserve(33); if (!value_buf) { return OpStatus::ERR_NO_MEMORY; } status = WebForms2Number::DoubleToString(val, value_buf); return status; } return OpStatus::OK; }
void OpNumberEdit::UpdateButtonState() { double value_number; if (HasValue() && GetValue(value_number)) { BOOL is_changeable = IsEnabled() && !m_edit->IsReadOnly(); BOOL enable_down_button = is_changeable; if (enable_down_button && !m_wrap_around) { double dummy_result_value; OP_STATUS status = WebForms2Number::StepNumber(value_number, m_min_value, m_max_value, m_step_base, m_step, -1, m_wrap_around, TRUE, /* fuzzy step, be helpful. */ dummy_result_value); if (OpStatus::IsError(status)) { enable_down_button = FALSE; } } m_spinner->SetDownEnabled(enable_down_button); BOOL enable_up_button = is_changeable && (m_wrap_around || value_number < m_max_value); if (enable_up_button && !m_wrap_around) { double dummy_result_value; OP_STATUS status = WebForms2Number::StepNumber(value_number, m_min_value, m_max_value, m_step_base, m_step, 1, m_wrap_around, TRUE, /* fuzzy step, be helpful. */ dummy_result_value); if (OpStatus::IsError(status)) { enable_up_button = FALSE; } } m_spinner->SetUpEnabled(enable_up_button); } }
bool wxRegKey::RenameValue(const wxString& szValueOld, const wxString& szValueNew) { bool ok = true; if ( HasValue(szValueNew) ) { wxLogError(_("Registry value '%s' already exists."), szValueNew); ok = false; } if ( !ok || !CopyValue(szValueOld, *this, szValueNew) || !DeleteValue(szValueOld) ) { wxLogError(_("Failed to rename registry value '%s' to '%s'."), szValueOld, szValueNew); return false; } return true; }
/// \brief rename duplicate labels from clipboard /// \param existingLabels - list with existing state machine object labels /// \param clipboardLabels - clipboard object labels /// \param labelMappings - contains mapping for clipboard labels. map does /// contain non-renamed labels void CStateMachineClipboardPreprocessor::RenameDuplicates( const list<IHashString *> &existingLabels, const vector<StdString> &clipboardLabels, map<StdString, StdString> &labelMappings ) { TCHAR chBuf[4]; vector<StdString>::const_iterator itClipboard = clipboardLabels.begin(); for( ; itClipboard != clipboardLabels.end(); ++itClipboard ) { StdString mappedLabel = *itClipboard; int counter = 0; while( HasValue( existingLabels, mappedLabel ) || labelMappings.count( mappedLabel ) > 0 || count( clipboardLabels.begin(), clipboardLabels.end(), mappedLabel ) > 0 ) { _itot( ++counter, chBuf, 10 ); mappedLabel = *itClipboard + chBuf; } if( counter > 0 ) { labelMappings.insert( make_pair( *itClipboard, mappedLabel ) ); } } }
void WebFeedContentElement::SaveL(WriteBuffer &buf, BOOL force_tags) { BOOL is_plain_text = IsPlainText(); BOOL in_cdata = FALSE; if (!is_plain_text || force_tags) { if (!is_plain_text) { buf.Append("<content type=\""); buf.AppendOpString(&m_type); buf.Append("\"><![CDATA["); in_cdata = TRUE; } else buf.Append("<content>"); } if (HasValue()) { if (!IsBinary()) if (in_cdata) buf.Append(Data()); else buf.AppendQuotedL(Data()); else buf.AppendBinaryL(m_value, m_value_length); } if (!is_plain_text || force_tags) { if (in_cdata) buf.Append("]]>"); buf.Append("</content>"); } }
bool mitk::TemporoSpatialStringProperty::HasValueByTimeStep(const TimeStepType& timeStep, bool allowClose) const { return HasValue(timeStep, 0, allowClose, true); };
bool mitk::TemporoSpatialStringProperty::HasValueBySlice(const IndexValueType& zSlice, bool allowClose) const { return HasValue(0, zSlice, true, allowClose); };
//! Gets the value at the current position of this reader. ItemType Value() { assert(HasValue()); return current_; }
void OpNumberEdit::ChangeNumber(int direction) { OP_ASSERT(direction != 0); double delta = direction * m_step; double value_number; if (HasValue() && GetValue(value_number)) { value_number = WebForms2Number::SnapToStep(value_number, m_step_base, m_step, direction); double result_value; OP_STATUS status = WebForms2Number::StepNumber(value_number, m_min_value, m_max_value, m_step_base, m_step, direction, m_wrap_around, TRUE, /* fuzzy step, be helpful. */ result_value); if (OpStatus::IsSuccess(status)) { SetNumberValue(result_value); } } else if (m_wrap_around) { // If we have a wrappable number control and the user // clicks up or down, start the number even if there was none from the beginning. double value_number = delta >= 0 ? m_min_value : m_max_value; SetNumberValue(value_number); } else { // Not wrap around and no current content. if (m_min_value > m_max_value) { return; } if (delta >= 0) { // some low value if (m_min_value != -DBL_MAX) { SetNumberValue(m_min_value); } else if (m_max_value >= 0.0) { SetNumberValue(0.0); } else { SetNumberValue(m_max_value); // What else? -DBL_MAX? } } else { // some high value if (m_max_value != DBL_MAX) { SetNumberValue(m_max_value); } else if (m_min_value <= 0.0) { SetNumberValue(0.0); } else { SetNumberValue(m_min_value); // What else? DBL_MAX? } } } if (listener) { listener->OnChangeWhenLostFocus(this); // since normal OnChange is filtered } }
void g1() { float &fr = f1(15); int &ir = f1(HasValue()); }