std::basic_string<Ch,Tr> basic_format<Ch,Tr> ::str() const { dumped_=true; if(items_.size()==0) return prefix_; if( cur_arg_ < num_args_) if( exceptions() & io::too_few_args_bit ) boost::throw_exception(io::too_few_args()); // not enough variables have been supplied ! unsigned long sz = prefix_.size(); unsigned long i; for(i=0; i < items_.size(); ++i) sz += items_[i].res_.size() + items_[i].appendix_.size(); string_t res; res.reserve(sz); res += prefix_; for(i=0; i < items_.size(); ++i) { const format_item_t& item = items_[i]; res += item.res_; if( item.argN_ == format_item_t::argN_tabulation) { BOOST_ASSERT( item.pad_scheme_ & format_item_t::tabulation); std::streamsize n = item.state_.width_ - res.size(); if( n > 0 ) res.append( n, item.state_.fill_ ); } res += item.appendix_; } return res; }
/// Default constructor. fstream::fstream (void) : ios_base (), m_fd (-1), m_Filename () { exceptions (goodbit); }
typename basic_format<Ch, Tr, Alloc>::string_type basic_format<Ch,Tr, Alloc>:: str () const { if(items_.size()==0) return prefix_; if( cur_arg_ < num_args_) if( exceptions() & io::too_few_args_bit ) // not enough variables supplied boost::throw_exception(io::too_few_args(cur_arg_, num_args_)); unsigned long i; string_type res; res.reserve(size()); res += prefix_; for(i=0; i < items_.size(); ++i) { const format_item_t& item = items_[i]; res += item.res_; if( item.argN_ == format_item_t::argN_tabulation) { BOOST_ASSERT( item.pad_scheme_ & format_item_t::tabulation); if( static_cast<size_type>(item.fmtstate_.width_) > res.size() ) res.append( static_cast<size_type>(item.fmtstate_.width_) - res.size(), item.fmtstate_.fill_ ); } res += item.appendix_; } dumped_=true; return res; }
void raw_ios::process_exception() { if (!((_state |= external_state()) & raw_ios::statebit)) _state = badbit ; if (_state & exceptions()) throw ; }
/// Destructor. Closes if still open, but without throwing. fstream::~fstream (void) throw() { clear (goodbit); exceptions (goodbit); close(); assert (!(rdstate() & badbit) && "close failed in the destructor! This may lead to loss of user data. Please call close() manually and either enable exceptions or check the badbit."); }
//_________________________________________________________ void ConfigWidget::save( void ) { // create internal settings and load from rc files m_internalSettings = InternalSettingsPtr( new InternalSettings() ); m_internalSettings->load(); // apply modifications from ui m_internalSettings->setTitleAlignment( m_ui.titleAlignment->currentIndex() ); m_internalSettings->setButtonSize( m_ui.buttonSize->currentIndex() ); m_internalSettings->setDrawBorderOnMaximizedWindows( m_ui.drawBorderOnMaximizedWindows->isChecked() ); m_internalSettings->setDrawSizeGrip( m_ui.drawSizeGrip->isChecked() ); m_internalSettings->setAnimationsEnabled( m_ui.animationsEnabled->isChecked() ); m_internalSettings->setAnimationsDuration( m_ui.animationsDuration->value() ); // save configuration m_internalSettings->save(); // save standard configuration ExceptionList::writeConfig( m_internalSettings.data(), m_configuration.data() ); // get list of exceptions and write InternalSettingsList exceptions( m_ui.exceptions->exceptions() ); ExceptionList( exceptions ).writeConfig( m_configuration ); // sync configuration m_configuration->sync(); setChanged( false ); // needed to tell kwin to reload when running from external kcmshell QDBusMessage message = QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig"); QDBusConnection::sessionBus().send(message); }
/// Opens \p filename in \p mode. fstream::fstream (const char* filename, openmode mode) : ios_base (), m_fd (-1), m_Filename () { exceptions (goodbit); open (filename, mode); }
/// Attaches to \p nfd of \p filename. fstream::fstream (int nfd, const char* filename) : ios_base (), m_fd (-1), m_Filename () { exceptions (goodbit); attach (nfd, filename); }
basic_ios& copyfmt(const ios& right) { fill(right.fill()); flags(right.flags() ); exceptions(right.exceptions()); width(right.width()); precision(right.precision()); return *this; }
/** * Throws \a mostRecentException only if the stream is enabled * to throw exceptions when failbit is set. * You can set this behavior with the following line of code: * @code * ffstreamobject.exceptions(ifstream::failbit); * @endcode * where \a ffstreamobject is the name of your stream object. */ inline void conditionalThrow(void) throw(FFStreamError) { if (exceptions() & std::fstream::failbit) { GPSTK_THROW(mostRecentException); } };
/// Creates an output string stream, initializing the buffer with v. ostringstream::ostringstream (const string& v) : ostream() ,_buffer (v) ,_flags (0) ,_width (0) ,_base (10) ,_precision (2) { exceptions (goodbit); ostream::link (_buffer); }
/// Creates an output string stream linked to the given memory area. ostringstream::ostringstream (void* p, size_t n) noexcept : ostream() ,_buffer() ,_flags (0) ,_width (0) ,_base (10) ,_precision (2) { exceptions (goodbit); link (p, n); }
/// Creates an output string stream, initializing the buffer with v. ostringstream::ostringstream (const string& v) : ostream (), m_Buffer (v), m_Flags (0), m_Width (0), m_Base (10), m_Precision (2) { exceptions (goodbit); ostream::link (m_Buffer); }
/// Creates an output string stream linked to the given memory area. ostringstream::ostringstream (void* p, size_t n) : ostream (), m_Buffer (), m_Flags (0), m_Width (0), m_Base (10), m_Precision (2) { exceptions (goodbit); link (p, n); }
bool CompiledMethod::is_rescue_target(STATE, int ip) { Tuple* table = exceptions(); if(table->nil_p()) return false; for(size_t i = 0; i < table->num_fields(); i++) { Tuple* entry = as<Tuple>(table->at(state, i)); if(as<Fixnum>(entry->at(state, 2))->to_native() == ip) return true; } return false; }
basic_format<Ch,Tr, Alloc>& basic_format<Ch,Tr, Alloc>:: clear_bind (int argN) { // remove the bind of ONE argument then clear() if(argN<1 || argN > num_args_ || bound_.size()==0 || !bound_[argN-1] ) { if( exceptions() & io::out_of_range_bit) boost::throw_exception(io::out_of_range(argN, 1, num_args_+1 ) ); else return *this; } bound_[argN-1]=false; clear(); return *this; }
basic_format<Ch,Tr>& basic_format<Ch,Tr> ::clear_bind(int argN) // cancel the binding of ONE argument, and clear() { if(argN<1 || argN > num_args_ || bound_.size()==0 || !bound_[argN-1] ) { if( exceptions() & io::out_of_range_bit ) boost::throw_exception(io::out_of_range()); // arg not in range. else return *this; } bound_[argN-1]=false; clear(); return *this; }
void raw_ios::_throw_failure() { if (!is_open()) throw failure_exception(_err_stream_closed, (iostate)closebit) ; iostate error_state = (iostate)(rdstate() & exceptions()) ; const char *errmsg = _err_stream_unknown ; if (error_state & badbit) { error_state = badbit ; errmsg = _err_stream_bad ; } else if (error_state & eofbit) { error_state = eofbit ; errmsg = _err_stream_eof ; } else if (error_state & failbit) { error_state = failbit ; errmsg = _err_stream_failed ; } throw failure_exception(errmsg, error_state) ; }
/// override open() to reset the header /// @param filename the name of the ASCII SP3 format file to be opened /// @param mode the ios::openmode to be used virtual void open(const char* filename, std::ios::openmode mode) { FFTextStream::open(filename, mode); header = SP3Header(); warnings.clear(); // for close() later wroteEOF = writingMode = false; if( (mode & std::ios::out) && !(mode & std::ios::in) ) writingMode = true; // this is necessary in order for SP3Data::reallyGetRecord() to // process the last line in the file when there is no EOF record...why? if(mode & std::ios::in) exceptions(std::ifstream::failbit); }
//___________________________________________________ bool Factory::readConfig() { bool changed( false ); /* always reload helper this is needed to properly handle color contrast settings changed */ helper().invalidateCaches(); helper().reloadConfig(); // create a config object KConfig config("oxygenrc"); KConfigGroup group( config.group("Windeco") ); Configuration configuration( group ); if( configuration.opacityFromStyle() ) { configuration.readBackgroundOpacity( config.group("Common") ); } if( !( configuration == defaultConfiguration() ) ) { setDefaultConfiguration( configuration ); changed = true; } // read exceptionsreadConfig ExceptionList exceptions( config ); if( !( exceptions == _exceptions ) ) { _exceptions = exceptions; changed = true; } // read shadowCache configuration changed |= shadowCache().readConfig( config ); // background pixmap { KConfigGroup group( config.group("Common") ); helper().setBackgroundPixmap( group.readEntry( "BackgroundPixmap", "" ) ); } return changed; }
void be_operation::GenerateImpureRequestCall (be_ClientImplementation & source) { be_OpStubGenerator stub ( stubClassname, opKey, LocalName (), StubSignature (OP_Implementation), returnType, is_oneway (), arguments, exceptions (), context (), local_name ()->get_string () ); stub.Generate (source); }
void UmlOperation::write_exceptions(FileOut & out) { const Q3ValueList<UmlTypeSpec> excpts = exceptions(); Q3ValueList<UmlTypeSpec>::ConstIterator iter; for (iter = excpts.begin(); iter != excpts.end(); ++iter) { const UmlTypeSpec & e = *iter; if (e.type != 0) { out.indent(); out << "<raisedException"; out.idref(e.type); out << "/>\n"; } else if (!e.explicit_type.isEmpty()) { out.indent(); out << "<raisedException"; out.idref_datatype(e.explicit_type); out << "/>\n"; } } }
void UmlOperation::gen_cpp_decl(QByteArray s, bool descr) { const char * p = bypass_comment(s); if (! descr) { write((cppVisibility() == DefaultVisibility) ? visibility() : cppVisibility(), cppLanguage); fw.write(": "); p = bypass_comment(s); } else p = s; const QList<UmlParameter> & pa = params(); unsigned npa = pa.count(); unsigned rank; while (*p) { if (!strncmp(p, "${comment}", 10)) p += 10; else if (!strncmp(p, "${description}", 14)) p += 14; else if (!strncmp(p, "${friend}", 9)) { p += 9; if (isCppFriend()) fw.write("friend "); } else if (!strncmp(p, "${static}", 9)) { p += 9; if (isClassMember()) fw.write("static "); } else if (!strncmp(p, "${inline}", 9)) { p += 9; if (isCppInline()) fw.write("inline "); } else if (!strncmp(p, "${virtual}", 10)) { p += 10; if (isCppVirtual()) fw.write("virtual "); } else if (!strncmp(p, "${type}", 7)) { p += 7; write(returnType(), cppLanguage); } else if (!strncmp(p, "${name}", 7)) { p += 7; writeq(compute_name(cppNameSpec())); } else if (!strncmp(p, "${(}", 4)) { p += 4; fw.write('('); } else if (!strncmp(p, "${)}", 4)) { p += 4; fw.write(')'); } else if (!strncmp(p, "${const}", 8)) { p += 8; if (isCppConst()) fw.write(" const"); } else if (!strncmp(p, "${volatile}", 11)) { p += 11; if (isVolatile()) fw.write(" volatile"); } else if (!strncmp(p, "${throw}", 8)) { p += 8; const char * sep = " throw ("; QList<UmlTypeSpec> e = exceptions(); unsigned n = e.count(); unsigned index2; for (index2 = 0; index2 != n; index2 += 1) { fw.write(sep); sep = ", "; write(e[index2], cppLanguage); } if (index2 != 0) fw.write(')'); else if (CppSettings::operationForceThrow()) fw.write(" throw ()"); } else if (sscanf(p, "${t%u}", &rank) == 1) { p = strchr(p, '}') + 1; if (rank < npa) write(pa[rank].type, cppLanguage); else fw.write("???"); } else if (sscanf(p, "${p%u}", &rank) == 1) { p = strchr(p, '}') + 1; if (rank < pa.count()) writeq(pa[rank].name); else fw.write("???"); } else if (sscanf(p, "${v%u}", &rank) == 1) { p = strchr(p, '}') + 1; if (rank >= pa.count()) fw.write("???"); else if (! pa[rank].default_value.isEmpty()) { fw.write(" = "); writeq(pa[rank].default_value); } } else if (!strncmp(p, "${abstract}", 11)) { if (isAbstract()) fw.write("= 0 "); break; } else if (!strncmp(p, "${stereotype}", 13)) { p += 13; // get/set relation with multiplicity > 1 UmlClassMember * m = getOf(); if ((m != 0) || ((m = setOf()) != 0)) writeq(CppSettings::relationAttributeStereotype(m->stereotype())); } else if (!strncmp(p, "${association}", 14)) { p += 14; // get/set relation with multiplicity > 1 UmlClassMember * m = getOf(); if (((m != 0) || ((m = setOf()) != 0)) && (m->kind() == aRelation)) write(((UmlRelation *) m)->association(), cppLanguage); } else if (*p == '\r') p += 1; else if (*p == '\n') { if (descr) { fw.write("<br />"); p += 1; } else { fw.write(' '); do p += 1; while ((*p != 0) && (*p <= ' ')); } } else if ((*p == '{') || (*p == ';')) { if (descr) fw.write(*p++); else break; } else if (*p == '@') manage_alias(p); else writeq(*p++); } }
PosixFdOutputStream(std::string const & rfilename, uint64_t const rbuffersize = 64*1024) : PosixFdOutputStreamBuffer(rfilename,rbuffersize), std::ostream(this) { exceptions(std::ios::badbit); }
Polyhedron * kaleido(char *sym, int need_coordinates, int need_edgelist, int need_approx, int just_list) { Polyhedron *P; /* * Allocate a Polyhedron structure P. */ if (!(P = polyalloc())) return 0; /* * Unpack input symbol into P. */ if (!unpacksym(sym, P)) return 0; /* * Find Mebius triangle, its density and Euler characteristic. */ if (!moebius(P)) return 0; /* * Decompose Schwarz triangle. */ if (!decompose(P)) return 0; /* * Find the names of the polyhedron and its dual. */ if (!guessname(P)) return 0; if (just_list) return P; /* * Solve Fundamental triangles, optionally printing approximations. */ if (!newton(P,need_approx)) return 0; /* * Deal with exceptional polyhedra. */ if (!exceptions(P)) return 0; /* * Count edges and faces, update density and characteristic if needed. */ if (!count(P)) return 0; /* * Generate printable vertex configuration. */ if (!configuration(P)) return 0; /* * Compute coordinates. */ if (!need_coordinates && !need_edgelist) return P; if (!vertices(P)) return 0; if (!faces (P)) return 0; /* * Compute edgelist. */ if (!need_edgelist) return P; if (!edgelist(P)) return 0; return P; }
const_shared_ptr<Result> OpenExpression::Evaluate( const shared_ptr<ExecutionContext> context, const shared_ptr<ExecutionContext> closure) const { // need to handle in-band errors // return file handle // return platform-dependent error codes; should handle mapping to platform-independent codes in std lib. // we assume that our validation pass caught any argument length issues auto path_argument_expression = GetArgumentListRef()->GetData(); auto path_argument_evaluation = path_argument_expression->Evaluate(context, closure); auto index = 0; auto result_code = 0; auto result_message = make_shared<string>(); auto errors = path_argument_evaluation->GetErrors(); if (ErrorList::IsTerminator(errors)) { auto path = path_argument_evaluation->GetData<string>(); auto mode_argument_expression = GetArgumentListRef()->GetNext()->GetData(); auto mode_argument_evaluation = mode_argument_expression->Evaluate( context, closure); errors = mode_argument_evaluation->GetErrors(); if (ErrorList::IsTerminator(errors)) { std::ios::openmode open_mode = std::ios::openmode(); auto mode_definition = mode_argument_evaluation->GetData<Record>()->GetDefinition(); if (*static_pointer_cast<const bool>( mode_definition->GetSymbol(*Builtins::STREAM_MODE_IN_NAME)->GetValue()) == true) { open_mode = open_mode | std::ios::in; } if (*static_pointer_cast<const bool>( mode_definition->GetSymbol(*Builtins::STREAM_MODE_OUT_NAME)->GetValue()) == true) { open_mode = open_mode | std::ios::out; } if (*static_pointer_cast<const bool>( mode_definition->GetSymbol( *Builtins::STREAM_MODE_BINARY_NAME)->GetValue()) == true) { open_mode = open_mode | std::ios::binary; } if (*static_pointer_cast<const bool>( mode_definition->GetSymbol(*Builtins::STREAM_MODE_ATE_NAME)->GetValue()) == true) { open_mode = open_mode | std::ios::ate; } if (*static_pointer_cast<const bool>( mode_definition->GetSymbol(*Builtins::STREAM_MODE_APP_NAME)->GetValue()) == true) { open_mode = open_mode | std::ios::app; } if (*static_pointer_cast<const bool>( mode_definition->GetSymbol( *Builtins::STREAM_MODE_TRUNC_NAME)->GetValue()) == true) { open_mode = open_mode | std::ios::trunc; } auto stream = make_shared<fstream>(); stream->exceptions(std::ifstream::failbit | std::ifstream::badbit); try { stream->open(*path, open_mode); // add stream to file handle list // N.B. that this process is not synchronized index = Builtins::get_file_handle_map()->size(); Builtins::get_file_handle_map()->insert( std::pair<int, volatile_shared_ptr<fstream>>(index, stream)); } catch (std::fstream::failure &e) { result_code = errno; result_message = make_shared<string>( std::strerror(result_code)); } } } auto type_table = closure->GetTypeTable(); auto error_list_type_result = Builtins::get_error_list_type_specifier()->GetType(type_table, RETURN); assert(ErrorList::IsTerminator(error_list_type_result->GetErrors())); auto error_list_type = error_list_type_result->GetData<TypeDefinition>(); if (result_code == 0) { auto result = make_shared<Sum>(Builtins::INT_RESULT_DATA_NAME, make_shared<int>(index)); return make_shared<Result>(result, errors); } else { auto error_symbol_map = make_shared<symbol_map>(); auto insert_result = error_symbol_map->insert( std::pair<const string, const_shared_ptr<Symbol>>( *Builtins::ERROR_CODE_NAME, make_shared<Symbol>(make_shared<int>(result_code)))); assert(insert_result.second); insert_result = error_symbol_map->insert( std::pair<const string, const_shared_ptr<Symbol>>( *Builtins::ERROR_MESSAGE_NAME, make_shared<Symbol>(result_message))); assert(insert_result.second); auto error_symbol_table = make_shared<SymbolTable>(Modifier::Type::NONE, error_symbol_map); auto error = make_shared<Record>(error_symbol_table); auto error_list_symbol_map = make_shared<symbol_map>(); insert_result = error_list_symbol_map->insert( std::pair<const string, const_shared_ptr<Symbol>>( *Builtins::ERROR_LIST_DATA_NAME, make_shared<Symbol>( Builtins::get_error_type_specifier(), error))); assert(insert_result.second); auto terminator = static_pointer_cast<const Record>( error_list_type->GetDefaultValue(type_table)); auto error_list_sum = make_shared<Sum>(TypeTable::GetNilName(), terminator); insert_result = error_list_symbol_map->insert( std::pair<const string, const_shared_ptr<Symbol>>( *Builtins::ERROR_LIST_NEXT_NAME, make_shared<Symbol>( Builtins::get_error_list_maybe_type_specifier(), error_list_sum))); assert(insert_result.second); auto error_list_symbol_table = make_shared<SymbolTable>( Modifier::Type::NONE, error_list_symbol_map); auto error_list = make_shared<Record>(error_list_symbol_table); auto result = make_shared<Sum>(Builtins::INT_RESULT_ERRORS_NAME, error_list); return make_shared<Result>(result, errors); } }
void UmlOperation::gen_uml_decl() { if (isAbstract()) fw.write("abstract, "); if (isClassMember()) fw.write("static, "); write(visibility()); writeq(name()); const QList<UmlParameter> & pa = params(); unsigned npa = pa.count(); unsigned rank; const char * sep = "("; for (rank = 0; rank != npa; rank += 1) { const UmlParameter & p = pa[rank]; fw.write(sep); sep = ", "; switch (p.dir) { case InputOutputDirection: fw.write("inout "); break; case InputDirection: fw.write("in "); break; default: // OutputDirection fw.write("out "); } writeq(p.name); fw.write(" : "); write(p.type); QByteArray s = p.default_value; if (!s.isEmpty()) { if (s[0] != '=') fw.write(" = "); writeq(s); } } fw.write((rank == 0) ? "() : " : ") : "); write(returnType()); sep = ", exceptions : "; const QList<UmlTypeSpec> e = exceptions(); unsigned n = e.count(); for (unsigned index2 = 0; index2 != n; index2 += 1) { fw.write(sep); sep = ", "; write(e[index2]); } }
//platform-independent exec_stream_t member functions exec_stream_t::exec_stream_t() { m_impl=new impl_t; exceptions( true ); }
exec_stream_t::exec_stream_t( std::string const & program, std::string const & arguments ) { m_impl=new impl_t; exceptions( true ); start( program, arguments ); }
void UmlOperation::gen_java_decl(QByteArray s, bool descr) { const char * p = bypass_comment(s); const QList<UmlParameter> & pa = params(); unsigned npa = pa.count(); unsigned rank; while (*p) { if (!strncmp(p, "${comment}", 10)) p += 10; else if (!strncmp(p, "${description}", 14)) p += 14; else if (!strncmp(p, "${final}", 8)) { p += 8; if (isJavaFinal()) fw.write("final "); } else if (!strncmp(p, "${visibility}", 13)) { p += 13; UmlItem::write(visibility(), javaLanguage); fw.write(' '); } else if (!strncmp(p, "${static}", 9)) { p += 9; if (isClassMember()) fw.write("static "); } else if (!strncmp(p, "${abstract}", 11)) { p += 11; if (isAbstract()) fw.write("abstract "); } else if (!strncmp(p, "${synchronized}", 15)) { p += 15; if (isJavaSynchronized()) fw.write("synchronized "); } else if (!strncmp(p, "${type}", 7)) { p += 7; write(returnType(), javaLanguage); } else if (!strncmp(p, "${name}", 7)) { p += 7; writeq(compute_name(javaNameSpec())); } else if (!strncmp(p, "${(}", 4)) { p += 4; fw.write('('); } else if (!strncmp(p, "${)}", 4)) { p += 4; fw.write(')'); } else if (!strncmp(p, "${throws}", 9)) { p += 9; const char * sep = " throws "; const QList<UmlTypeSpec> e = exceptions(); unsigned n = e.count(); for (unsigned index2 = 0; index2 != n; index2 += 1) { fw.write(sep); sep = ", "; write(e[index2], javaLanguage); } } else if (!strncmp(p, "${staticnl}", 11)) break; else if (sscanf(p, "${t%u}", &rank) == 1) { p = strchr(p, '}') + 1; if (rank < npa) write(pa[rank].type, javaLanguage); else fw.write("???"); } else if (sscanf(p, "${p%u}", &rank) == 1) { p = strchr(p, '}') + 1; if (rank < npa) writeq(pa[rank].name); else fw.write("???"); } else if (!strncmp(p, "${stereotype}", 13)) { p += 13; // get/set relation with multiplicity > 1 UmlClassMember * m = getOf(); if ((m != 0) || ((m = setOf()) != 0)) writeq(JavaSettings::relationAttributeStereotype(m->stereotype())); } else if (!strncmp(p, "${association}", 14)) { p += 14; // get/set relation with multiplicity > 1 UmlClassMember * m = getOf(); if (((m != 0) || ((m = setOf()) != 0)) && (m->kind() == aRelation)) write(((UmlRelation *) m)->association(), javaLanguage); } else if (!strncmp(p, "${@}", 4)) p += 4; else if (*p == '\r') p += 1; else if (*p == '\n') { if (descr) { fw.write("<br />"); p += 1; } else { fw.write(' '); do p += 1; while ((*p != 0) && (*p <= ' ')); } } else if ((*p == '{') || (*p == ';')) { if (descr) fw.write(*p++); else break; } else if (*p == '@') manage_alias(p); else writeq(*p++); } }