void FileFormatImplementation::SetImageProperty( const IsoString& id, const Variant& value ) { IsoString tid = id.Trimmed(); if ( !tid.IsEmpty() && value.IsValid() ) { FileFormatPropertyArray::iterator i = m_data->properties.Search( tid ); if ( i != m_data->properties.End() ) i->value = value; else m_data->properties.Append( FileFormatProperty( tid, value ) ); } }
ProcessParameter::ProcessParameter( const Process& process, const IsoString& paramId ) { m_data = new ProcessParameterPrivate( (*API->Process->GetParameterByName)( process.Handle(), paramId.c_str() ) ); if ( m_data->handle == nullptr ) { if ( paramId.IsEmpty() ) throw Error( "ProcessParameter: Empty process parameter identifier specified" ); if ( !paramId.IsValidIdentifier() ) throw Error( "ProcessParameter: Invalid process parameter identifier specified: \'" + paramId + '\'' ); throw Error( "ProcessParameter: No parameter was found " "with the specified identifier \'" + paramId + "\' for process \'" + process.Id() + '\'' ); } }
void NumberProperty::addElement( IsoString elementName, IsoString value ) { if ( !value.IsEmpty() ) { INumberVectorProperty* nvp = m_property->getNumber(); INumber* np = nvp->np; int nnp = nvp->nnp; np = reinterpret_cast<INumber*>( realloc( np, (nnp + 1)*sizeof( INumber ) ) ); if ( np == nullptr ) throw std::bad_alloc(); strcpy( np->name, elementName.c_str() ); value.TryToDouble( np->value ); np->nvp = nvp; nvp->nnp++; nvp->np = np; } }
ProcessParameter::ProcessParameter( const ProcessParameter& table, const IsoString& colId ) { m_data = new ProcessParameterPrivate( (*API->Process->GetTableColumnByName)( table.m_data->handle, colId.c_str() ) ); if ( m_data->handle == nullptr ) { if ( table.IsNull() ) throw Error( "ProcessParameter: Null table parameter" ); if ( colId.IsEmpty() ) throw Error( "ProcessParameter: Empty table column parameter identifier specified" ); if ( !colId.IsValidIdentifier() ) throw Error( "ProcessParameter: Invalid table column parameter identifier specified: \'" + colId + '\'' ); if ( !table.IsTable() ) throw Error( "ProcessParameter: The specified parameter \'" + table.Id() + "\' is not a table parameter" ); throw Error( "ProcessParameter: No table column parameter was found " "with the specified identifier \'" + colId + "\' " "for table parameter \'" + table.Id() + "\' " "of process \'" + table.ParentProcess().Id() + '\'' ); } }
void ConvolutionFilterCodeDialog::__Button_Click( Button& sender, bool checked ) { if ( sender == Cancel_PushButton ) { Cancel(); } else if ( sender == Save_PushButton ) { try { IsoString sourceCode = FilterCode_TextBox.Text().ToUTF8().Trimmed(); if ( sourceCode.IsEmpty() ) throw Error( "Empty filter source code" ); filter = Filter::FromSource( sourceCode ); if ( !filter.IsValid() ) throw Error( "invalid filter" ); Ok(); return; } ERROR_HANDLER FilterCode_TextBox.Focus(); } }
FilterParser::token_list FilterParser::Tokenize( const IsoStringList& linesUTF8 ) { token_list tokenList; bool blockComment = false; int row = 0; for ( IsoStringList::const_iterator i = linesUTF8.Begin(); i < linesUTF8.End(); ++i, ++row ) { IsoString token; int tokenCol = 0; for ( IsoString::const_iterator j = i->Begin(); j < i->End(); ++j ) { if ( blockComment ) { if ( *j == '*' ) if ( ++j < i->End() ) if ( *j == '/' ) { blockComment = false; /* * Uncomment the next line to turn block comments into * separators. * tokenCol = j - i->Begin() + 1; */ } } else { bool lineComment = false; switch ( *j ) { case ' ': case '\t': if ( !token.IsEmpty() ) { tokenList.Add( Token( token, row, tokenCol ) ); token.Clear(); } for ( IsoString::const_iterator k = j; ++k < i->End(); ++j ) if ( *k != ' ' && *k != '\t' ) break; tokenCol = j - i->Begin() + 1; break; /* case ',': if ( token.IsEmpty() ) throw SourceCodeError( "Expected a token before ','", row+1, int( j - i->Begin() + 1 ) ); tokenList.Add( Token( token, row, tokenCol ) ); token.Clear(); tokenCol = j - i->Begin() + 1; break; */ case '{': case '}': if ( !token.IsEmpty() ) { tokenList.Add( Token( token, row, tokenCol ) ); token.Clear(); } tokenList.Add( Token( IsoString( *j ), row, int( j - i->Begin() ) ) ); tokenCol = j - i->Begin() + 1; break; case '/': if ( ++j < i->End() ) { if ( *j == '/' ) lineComment = true; else if ( *j == '*' ) { blockComment = true; /* * Uncomment the next lines to turn block comments into * separators. * if ( !token.IsEmpty() ) { tokenList.Add( Token( token, row, tokenCol ) ); token.Clear(); } */ } else token += *--j; } break; default: token += *j; break; } if ( lineComment ) break; } } if ( !token.IsEmpty() ) tokenList.Add( Token( token, row, tokenCol ) ); } return tokenList; }
void ExternalProcess::Write( const IsoString& text ) { if ( !text.IsEmpty() ) if ( (*API->ExternalProcess->WriteToExternalProcess)( handle, text.c_str(), text.Size() ) == api_false ) throw APIFunctionError( "WriteToExternalProcess" ); }
static void CriticalSignalHandler( int sig_num ) { sigset_t x; sigemptyset( &x ); sigaddset( &x, SIGSEGV ); sigaddset( &x, SIGBUS ); sigaddset( &x, SIGFPE ); sigaddset( &x, SIGILL ); sigaddset( &x, SIGPIPE ); //sigprocmask( SIG_UNBLOCK, &x, NULL ); pthread_sigmask( SIG_UNBLOCK, &x, NULL ); void* addrList[ STACK_DEPTH ]; size_t addrLen = backtrace( addrList, sizeof( addrList )/sizeof( void* ) ); char** symbolList = backtrace_symbols( addrList, addrLen ); IsoString details; if ( symbolList != NULL ) { if ( symbolList[0] != NULL ) { details = STACK_TRACE_TITLE + IsoString().Format( STACK_TRACE_HEADER, sig_num, symbolList[0] ); for ( size_t i = 1; i < addrLen; ++i ) { if ( symbolList[i] != NULL ) { IsoString addrOffsetStr; IsoString demangledFuncname = GetDemangledFunctionName( symbolList[i], addrOffsetStr ); details.AppendFormat( "%d: ", addrLen-i ); details += demangledFuncname; if ( !addrOffsetStr.IsEmpty() ) { details += "(+"; details += addrOffsetStr; details += ')'; } details += '\n'; } } details += STACK_TRACE_BOTTOM; fprintf( stderr, "%s", details.c_str() ); } // symbolList must be freed free( symbolList ); } switch ( sig_num ) { case SIGSEGV: throw EUnixSegmentationViolation( details ); case SIGBUS: throw EUnixBusError( details ); case SIGFPE: throw EUnixFloatingPointException( details ); case SIGILL: throw EUnixIllegalInstructionException( details ); case SIGPIPE: throw EUnixIBrokenPipeException( details ); default: throw UnixSignalException( sig_num, details ); } }