コード例 #1
0
// Accepts an HTML stream and tries to determine its encoding;
// if no encoding is detected, the default codec for this locale is returned.
// We use this function because Qt's QTextCodec::codecForHtml() function
// leaves a *lot* to be desired.
const QTextCodec& HTMLEncodingResolver::GetCodecForHTML( const QByteArray &raw_text )
{
    // Qt docs say Qt will take care of deleting
    // any QTextCodec objects on application exit

    QString ascii_data = raw_text;

    int head_end = ascii_data.indexOf( QRegExp( HEAD_END ) );

    if ( head_end != -1 )
    {
        QString head = Utility::Substring( 0, head_end, ascii_data );

        QRegExp encoding( ENCODING_ATTRIBUTE );
        head.indexOf( encoding );
        QTextCodec *encoding_codec = QTextCodec::codecForName( encoding.cap( 1 ).toAscii() );

        if ( encoding_codec != 0 )

            return *encoding_codec;

        QRegExp charset( "charset=([^\"]+)\"" );
        head.indexOf( charset );
        QTextCodec *charset_codec  = QTextCodec::codecForName( charset .cap( 1 ).toAscii() );

        if ( charset_codec != 0 )

            return *charset_codec;
    }

    // This is a workaround for a bug in QTextCodec which
    // expects the 'charset' attribute to always come after
    // the 'http-equiv' attribute
    ascii_data.replace( QRegExp( "<\\s*meta([^>]*)http-equiv=\"Content-Type\"([^>]*)>" ),
                                 "<meta http-equiv=\"Content-Type\" \\1 \\2>" );

    // If we couldn't find a codec ourselves,
    // we use Qt's function.
    QTextCodec &locale_codec   = *QTextCodec::codecForLocale();
    QTextCodec &detected_codec = *QTextCodec::codecForHtml( ascii_data.toAscii(), QTextCodec::codecForLocale() ); 

    if ( detected_codec.name() != locale_codec.name() )

        return detected_codec;

    // If that couldn't find anything, then let's test for UTF-8
    if ( IsValidUtf8( raw_text ) )

        return *QTextCodec::codecForName( "UTF-8" );

    // If everything fails, we fall back to the locale default
    return locale_codec;
}
コード例 #2
0
const char* FloatRegisterImpl::name() const {
  const char* names[number_of_registers] = {
    "F0",  "F1",   "F2",  "F3",   "F4",  "F5",   "F6",  "F7",   "F8",  "F9",
    "F10", "F11",  "F12", "F13",  "F14", "F15",  "F16", "F17",  "F18", "F19",
    "F20", "F21",  "F22", "F23",  "F24", "F25",  "F26", "F27",  "F28", "F29",
    "F30", "F31",  "F32", "F33?", "F34", "F35?", "F36", "F37?", "F38", "F39?",
    "F40", "F41?", "F42", "F43?", "F44", "F45?", "F46", "F47?", "F48", "F49?",
    "F50", "F51?", "F52", "F53?", "F54", "F55?", "F56", "F57?", "F58", "F59?",
    "F60", "F61?", "F62"
  };
  return is_valid() ? names[encoding()] : "fnoreg";
}
コード例 #3
0
QStringList QgsOpenVectorLayerDialog::openFile()
{

    QStringList selectedFiles;
    QgsDebugMsg( "Vector file filters: " + mVectorFileFilter );
    QString enc = encoding();
    QString title = tr( "Open an OGR Supported Vector Layer" );
    QgisGui::openFilesRememberingFilter( "lastVectorFileFilter", mVectorFileFilter, selectedFiles, enc,
                                         title );

    return selectedFiles;
}
コード例 #4
0
ファイル: p-t1.c プロジェクト: ffzg/PhiloLogic3
void Encoding ( hit *i )
   {
      Z32 j;

      for ( j = 0; j < FIELDS; j++ )
	 {
	    word_length = lens[j]; 
	    word_code = i->i[j] + negs[j];
	    
	    encoding();
	 }
   }
コード例 #5
0
ファイル: TextDecoder.cpp プロジェクト: kjthegod/WebKit
TextDecoder* TextDecoder::create(const String& label, const TextDecoderOptions& options, ExceptionState& exceptionState)
{
    WTF::TextEncoding encoding(label);
    // The replacement encoding is not valid, but the Encoding API also
    // rejects aliases of the replacement encoding.
    if (!encoding.isValid() || !strcasecmp(encoding.name(), "replacement")) {
        exceptionState.throwRangeError("The encoding label provided ('" + label + "') is invalid.");
        return 0;
    }

    return new TextDecoder(encoding, options.fatal(), options.ignoreBOM());
}
コード例 #6
0
const char* PredicateRegisterImpl::name() const {
  const char* names[number_of_registers] = {
      "pr0",   "pr1",   "pr2",   "pr3",   "pr4",   "pr5",   "pr6",   "pr7",
      "pr8",   "pr9",   "pr10",  "pr11",  "pr12", "pr13",   "pr14",  "pr15",
      "pr16",  "pr17",  "pr18",  "pr19",  "pr20",  "pr21",  "pr22",  "pr23",
      "pr24",  "pr25",  "pr26",  "pr27",  "pr28",  "pr29",  "pr30",  "pr31",
      "pr32",  "pr33",  "pr34",  "pr35",  "pr36",  "pr37",  "pr38",  "pr39",
      "pr40",  "pr41",  "pr42",  "pr43",  "pr44",  "pr45",  "pr46",  "pr47",
      "pr48",  "pr49",  "pr50",  "pr51",  "pr52",  "pr53",  "pr54",  "pr55",
      "pr56",  "pr57",  "pr58",  "pr59",  "pr60",  "pr61",  "pr62",  "pr63"
  };
  return is_valid() ? names[encoding()] : "noreg";
}
コード例 #7
0
ファイル: pkcs10.cpp プロジェクト: mingpen/OpenNT
HRESULT CPersistMemoryHelper2::Load(BLOB* pblob)
// Load from the indicated blob
	{
	OSSBUF encoding(World(), OSSBUF::keep);
	encoding.length = pblob->cbSize;
	encoding.value  = pblob->pBlobData;

	HRESULT hr = Load(encoding);
	if (hr == S_OK)
		m_isDirty = FALSE;

	return hr;
	}
コード例 #8
0
ファイル: textbuffer.cpp プロジェクト: KDE/libqinfinity
void TextBuffer::insertText( unsigned int pos,
    const QByteArray &data,
    unsigned int length,
    User *user )
{
    inf_text_buffer_insert_text( INF_TEXT_BUFFER(gobject()),
        pos, data.data(), data.length(), length,
        INF_USER(user->gobject()) );
    // TODO test me, I don't think this is used anywhere in kobby
    QInfinity::TextChunk chunk( encoding() );
    chunk.insertText( 0, data, data.length(), user->id() );
    inf_text_buffer_text_inserted( INF_TEXT_BUFFER(gobject()),
        pos, chunk.infChunk(), INF_USER(user->gobject()) );
}
コード例 #9
0
CPDF_Font* CPDF_InterForm::AddStandardFont(const CPDF_Document* pDocument,
                                           CFX_ByteString csFontName) {
  if (pDocument == NULL || csFontName.IsEmpty()) {
    return NULL;
  }
  CPDF_Font* pFont = NULL;
  if (csFontName == "ZapfDingbats") {
    pFont = ((CPDF_Document*)pDocument)->AddStandardFont(csFontName, NULL);
  } else {
    CPDF_FontEncoding encoding(PDFFONT_ENCODING_WINANSI);
    pFont = ((CPDF_Document*)pDocument)->AddStandardFont(csFontName, &encoding);
  }
  return pFont;
}
コード例 #10
0
ファイル: string.hpp プロジェクト: JesseChavez/rubinius
 void encoding(T state, Encoding* obj) {
   if(obj->nil_p() || (!CBOOL(ascii_only()) && obj->ascii_compatible())) {
     ascii_only(cNil);
     num_chars(nil<Fixnum>());
     valid_encoding(cNil);
   }
   if(byte_size() == 0 && !obj->nil_p() && obj->ascii_compatible()) {
     ascii_only(cTrue);
     num_chars(Fixnum::from(0));
     valid_encoding(cTrue);
   }
   encoding(obj);
   state->memory()->write_barrier(this, obj);
 }
コード例 #11
0
void CBC_OneDimWriter::CalcTextInfo(const CFX_ByteString& text,
                                    FXTEXT_CHARPOS* charPos,
                                    CFX_Font* cFont,
                                    FX_FLOAT geWidth,
                                    int32_t fontSize,
                                    FX_FLOAT& charsLen) {
  std::unique_ptr<CFX_UnicodeEncodingEx> encoding(
      FX_CreateFontEncodingEx(cFont));

  int32_t length = text.GetLength();
  uint32_t* pCharCode = FX_Alloc(uint32_t, text.GetLength());
  FX_FLOAT charWidth = 0;
  for (int32_t j = 0; j < text.GetLength(); j++) {
    pCharCode[j] = encoding->CharCodeFromUnicode(text[j]);
    int32_t glyp_code = encoding->GlyphFromCharCode(pCharCode[j]);
    int32_t glyp_value = cFont->GetGlyphWidth(glyp_code);
    FX_FLOAT temp = (FX_FLOAT)((glyp_value)*fontSize / 1000.0);
    charWidth += temp;
  }
  charsLen = charWidth;
  FX_FLOAT leftPositon = (FX_FLOAT)(geWidth - charsLen) / 2.0f;
  if (leftPositon < 0 && geWidth == 0) {
    leftPositon = 0;
  }
  FX_FLOAT penX = 0.0;
  FX_FLOAT penY =
      (FX_FLOAT)FXSYS_abs(cFont->GetDescent()) * (FX_FLOAT)fontSize / 1000.0f;
  FX_FLOAT left = leftPositon;
  FX_FLOAT top = 0.0;
  charPos[0].m_OriginX = penX + left;
  charPos[0].m_OriginY = penY + top;
  charPos[0].m_GlyphIndex = encoding->GlyphFromCharCode(pCharCode[0]);
  charPos[0].m_FontCharWidth = cFont->GetGlyphWidth(charPos[0].m_GlyphIndex);
#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
  charPos[0].m_ExtGID = charPos[0].m_GlyphIndex;
#endif
  penX += (FX_FLOAT)(charPos[0].m_FontCharWidth) * (FX_FLOAT)fontSize / 1000.0f;
  for (int32_t i = 1; i < length; i++) {
    charPos[i].m_OriginX = penX + left;
    charPos[i].m_OriginY = penY + top;
    charPos[i].m_GlyphIndex = encoding->GlyphFromCharCode(pCharCode[i]);
    charPos[i].m_FontCharWidth = cFont->GetGlyphWidth(charPos[i].m_GlyphIndex);
#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
    charPos[i].m_ExtGID = charPos[i].m_GlyphIndex;
#endif
    penX +=
        (FX_FLOAT)(charPos[i].m_FontCharWidth) * (FX_FLOAT)fontSize / 1000.0f;
  }
  FX_Free(pCharCode);
}
コード例 #12
0
String InspectorResource::sourceString() const
{
    if (!m_xmlHttpResponseText.isNull())
        return String(m_xmlHttpResponseText);

    String textEncodingName;
    RefPtr<SharedBuffer> buffer = resourceData(&textEncodingName);
    if (!buffer)
        return String();

    TextEncoding encoding(textEncodingName);
    if (!encoding.isValid())
        encoding = WindowsLatin1Encoding();
    return encoding.decode(buffer->data(), buffer->size());
}
コード例 #13
0
ファイル: dir.cpp プロジェクト: Omosofe/rubinius
  Object* Dir::read(STATE) {
    guard(state);

    struct dirent ent;
    struct dirent* entp = &ent;
    if(int erno = readdir_r(os(), entp, &entp)) {
      Exception::raise_errno_error(state, "readdir_r(3) failed", erno);
    }

    if(!entp) return cNil;

    String* str = String::create(state, ent.d_name);
    str->encoding(state, encoding());
    return str;
  }
コード例 #14
0
ファイル: gz_corpus.cpp プロジェクト: domarps/meta
document gz_corpus::next()
{
    class_label label{"[none]"};

    if (class_stream_)
        std::getline(class_stream_, static_cast<std::string&>(label));

    std::string line;
    std::getline(corpus_stream_, line);

    document doc{cur_id_++, label};
    doc.content(line, encoding());
    doc.mdata(next_metadata());

    return doc;
}
/**
 * Creates a new Expat parser. Called from the Java ExpatParser constructor.
 *
 * @param object the Java ExpatParser instance
 * @param javaEncoding the character encoding name
 * @param processNamespaces true if the parser should handle namespaces
 * @returns the pointer to the C Expat parser
 */
static jlong ExpatParser_initialize(JNIEnv* env, jobject object, jstring javaEncoding,
        jboolean processNamespaces) {
    // Allocate parsing context.
    UniquePtr<ParsingContext> context(new ParsingContext(object));
    if (context.get() == NULL) {
        jniThrowOutOfMemoryError(env, NULL);
        return 0;
    }

    context->processNamespaces = processNamespaces;

    // Create a parser.
    XML_Parser parser;
    ScopedUtfChars encoding(env, javaEncoding);
    if (encoding.c_str() == NULL) {
        return 0;
    }
    if (processNamespaces) {
        // Use '|' to separate URIs from local names.
        parser = XML_ParserCreateNS(encoding.c_str(), '|');
    } else {
        parser = XML_ParserCreate(encoding.c_str());
    }

    if (parser != NULL) {
        if (processNamespaces) {
            XML_SetNamespaceDeclHandler(parser, startNamespace, endNamespace);
            XML_SetReturnNSTriplet(parser, 1);
        }

        XML_SetCdataSectionHandler(parser, startCdata, endCdata);
        XML_SetCharacterDataHandler(parser, text);
        XML_SetCommentHandler(parser, comment);
        XML_SetDoctypeDeclHandler(parser, startDtd, endDtd);
        XML_SetElementHandler(parser, startElement, endElement);
        XML_SetExternalEntityRefHandler(parser, handleExternalEntity);
        XML_SetNotationDeclHandler(parser, notationDecl);
        XML_SetProcessingInstructionHandler(parser, processingInstruction);
        XML_SetUnparsedEntityDeclHandler(parser, unparsedEntityDecl);
        XML_SetUserData(parser, context.release());
    } else {
        jniThrowOutOfMemoryError(env, NULL);
        return 0;
    }

    return fromXMLParser(parser);
}
コード例 #16
0
ファイル: ksconfig.cpp プロジェクト: Fat-Zer/tdelibs
bool
KSpellConfig::writeGlobalSettings ()
{
  TDEConfigGroupSaver cs( kc,"KSpell" );

  kc->writeEntry ("KSpell_NoRootAffix",(int) noRootAffix(), true, true);
  kc->writeEntry ("KSpell_RunTogether", (int) runTogether(), true, true);
  kc->writeEntry ("KSpell_Dictionary", dictionary(), true, true);
  kc->writeEntry ("KSpell_DictFromList",(int) dictFromList(), true, true);
  kc->writeEntry ("KSpell_Encoding", (int) encoding(),
		  true, true);
  kc->writeEntry ("KSpell_Client", client(),
		  true, true);
  kc->sync();

  return true;
}
コード例 #17
0
void CSSStyleSheetResource::didAddClient(ResourceClient* c) {
    DCHECK(StyleSheetResourceClient::isExpectedType(c));
    // Resource::didAddClient() must be before setCSSStyleSheet(), because
    // setCSSStyleSheet() may cause scripts to be executed, which could destroy
    // 'c' if it is an instance of HTMLLinkElement. see the comment of
    // HTMLLinkElement::setCSSStyleSheet.
    Resource::didAddClient(c);

    if (hasClient(c) && m_didNotifyFirstData)
        static_cast<StyleSheetResourceClient*>(c)->didAppendFirstData(this);

    // |c| might be removed in didAppendFirstData, so ensure it is still a client.
    if (hasClient(c) && !isLoading()) {
        static_cast<StyleSheetResourceClient*>(c)->setCSSStyleSheet(
            resourceRequest().url(), response().url(), encoding(), this);
    }
}
コード例 #18
0
ファイル: textbuffer.cpp プロジェクト: KDE/libqinfinity
TextBuffer::TextBuffer( InfTextBuffer *infBuffer,
    QObject *parent,
    bool own_gobject )
    : Buffer( INF_BUFFER(infBuffer), parent, own_gobject )
    , m_codec( 0 )
    , m_encoder( 0 )
{
    m_codec = QTextCodec::codecForName( encoding().toAscii() );
    if( m_codec )
        m_encoder = m_codec->makeEncoder();
    erase_text_handler = g_signal_connect_after( gobject(),
        "text-erased", G_CALLBACK(TextBuffer::text_erased_cb),
        this );
    insert_text_handler = g_signal_connect_after( gobject(),
        "text-inserted", G_CALLBACK(TextBuffer::text_inserted_cb),
        this );
}
コード例 #19
0
bool InspectorResourceAgent::resourceContent(Frame* frame, const KURL& url, String* result)
{
    if (!frame)
        return false;

    String textEncodingName;
    RefPtr<SharedBuffer> buffer = InspectorResourceAgent::resourceData(frame, url, &textEncodingName);

    if (buffer) {
        TextEncoding encoding(textEncodingName);
        if (!encoding.isValid())
            encoding = WindowsLatin1Encoding();
        *result = encoding.decode(buffer->data(), buffer->size());
        return true;
    }

    return false;
}
コード例 #20
0
TextDecoder* TextDecoder::create(const String& label, const Dictionary& options, ExceptionState& exceptionState)
{
    WTF::TextEncoding encoding(label);
    // The replacement encoding is not valid, but the Encoding API also
    // rejects aliases of the replacement encoding.
    if (!encoding.isValid() || !strcasecmp(encoding.name(), "replacement")) {
        exceptionState.throwTypeError("The encoding label provided ('" + label + "') is invalid.");
        return 0;
    }

    bool fatal = false;
    options.get("fatal", fatal);

    bool ignoreBOM = false;
    options.get("ignoreBOM", ignoreBOM);

    return new TextDecoder(encoding, fatal, ignoreBOM);
}
コード例 #21
0
ファイル: document.cpp プロジェクト: KDE/kte-collaborative
void KDocumentTextBuffer::localTextInserted( KTextEditor::Document *document,
    const KTextEditor::Range &range )
{
    if ( m_aboutToClose ) return;

    emit localChangedText(range, user(), false);
    Q_UNUSED(document)

    textOpPerformed();
    if( m_user.isNull() ) {
        kDebug() << "Could not insert text: No local user set.";
        return;
    }
    unsigned int offset = cursorToOffset_kte(range.start());
    kDebug() << "local text inserted" << kDocument() << "( range" << range << ")" << m_user << "offset:" << offset;
    QInfinity::TextChunk chunk(encoding());
    QString text = kDocument()->text(range);
#ifdef ENABLE_TAB_HACK
    if ( text.contains('\t') ) {
        text = text.replace('\t', "    ");
        kDocument()->blockSignals(true);
        kDocument()->replaceText(range, text);
        kDocument()->blockSignals(false);
    }
#endif
    Q_ASSERT(encoder());
    if ( text.isEmpty() ) {
        kDebug() << "Skipping empty insert.";
        return;
    }
    QByteArray encodedText = codec()->fromUnicode( text );
    if ( encodedText.size() == 0 ) {
        kDebug() << "Got empty encoded text from non empty string "
                    "Skipping insertion";
    }
    else {
        chunk.insertText( 0, encodedText, countUnicodeCharacters(text), m_user->id() );
        blockRemoteInsert = true;
        kDebug() << "inserting chunk of size" << chunk.length() << "into local buffer" << kDocument()->url();
        insertChunk( offset, chunk, m_user );
        kDebug() << "done inserting chunk";
        checkConsistency();
    }
}
コード例 #22
0
void InspectorResourceAgent::resourceContent(ErrorString* errorString, Frame* frame, const KURL& url, String* result)
{
    if (!frame) {
        *errorString = "No frame to get resource content for";
        return;
    }

    String textEncodingName;
    RefPtr<SharedBuffer> buffer = InspectorResourceAgent::resourceData(frame, url, &textEncodingName);

    if (buffer) {
        TextEncoding encoding(textEncodingName);
        if (!encoding.isValid())
            encoding = WindowsLatin1Encoding();
        *result = encoding.decode(buffer->data(), buffer->size());
        return;
    }
    *errorString = "No resource with given URL found"; 
}
コード例 #23
0
bool StandardFeed::addItself(RootItem* parent) {
  // Now, add feed to persistent storage.
  QSqlDatabase database = qApp->database()->connection(metaObject()->className());
  bool ok;
  int new_id = DatabaseQueries::addFeed(database, parent->id(), parent->getParentServiceRoot()->accountId(), title(),
                                        description(), creationDate(), icon(), encoding(), url(), passwordProtected(),
                                        username(), password(), autoUpdateType(), autoUpdateInitialInterval(), type(), &ok);

  if (!ok) {
    // Query failed.
    return false;
  }
  else {
    // New feed was added, fetch is primary id from the database.
    setId(new_id);
    setCustomId(QString::number(new_id));
    return true;
  }
}
コード例 #24
0
ファイル: coding.c プロジェクト: cumirror/epoll_example
void coding_test() {
    char* encode;
    int encode_len;
    char* decode;
    int decode_len;

    if (encoding("abcd", 4, &encode, &encode_len) < 0) {
        return ;
    }

    printf("%.*s\n", encode_len - 4, encode + 4);

    if (decoding(encode + 4, encode_len - 4, &decode, &decode_len) < 0) {
        return ;
    }

    printf("%.*s\n", decode_len, decode);

}
コード例 #25
0
void CSSStyleSheetResource::checkNotify() {
    // Decode the data to find out the encoding and cache the decoded sheet text.
    if (data())
        setDecodedSheetText(decodedText());

    ResourceClientWalker<StyleSheetResourceClient> w(clients());
    while (StyleSheetResourceClient* c = w.next()) {
        markClientFinished(c);
        c->setCSSStyleSheet(resourceRequest().url(), response().url(), encoding(),
                            this);
    }

    // Clear raw bytes as now we have the full decoded sheet text.
    // We wait for all LinkStyle::setCSSStyleSheet to run (at least once)
    // as SubresourceIntegrity checks require raw bytes.
    // Note that LinkStyle::setCSSStyleSheet can be called from didAddClient too,
    // but is safe as we should have a cached ResourceIntegrityDisposition.
    clearData();
}
コード例 #26
0
ファイル: gz_corpus.cpp プロジェクト: MGKhKhD/meta
document gz_corpus::next()
{
    class_label label{"[none]"};

    if (class_stream_)
        std::getline(class_stream_, static_cast<std::string&>(label));

    std::string line;
    std::getline(corpus_stream_, line);

    document doc{cur_id_++, label};
    doc.content(line, encoding());

    auto mdata = next_metadata();
    if (store_full_text())
        mdata.insert(mdata.begin(), metadata::field{doc.content()});
    doc.mdata(std::move(mdata));

    return doc;
}
コード例 #27
0
ファイル: pkcs10.cpp プロジェクト: mingpen/OpenNT
HRESULT CPersistMemoryHelper2::Save(BLOB* pblob, BOOL fClearDirty)
// Save ourselves to the blob, clearing our dirty flag if asked
	{
	OSSBUF encoding(World(), OSSBUF::free);
	HRESULT hr = Save(encoding);
	if (SUCCEEDED(hr))
		{
		pblob->cbSize = encoding.length;
		pblob->pBlobData = (BYTE*)CopyToTaskMem(encoding.length, encoding.value);

		if (pblob->pBlobData == NULL)
			return E_OUTOFMEMORY;

		if (fClearDirty)
			m_isDirty = FALSE;

		return S_OK;
		}
	return hr;
	}
コード例 #28
0
ファイル: file_corpus.cpp プロジェクト: eektguj/meta
document file_corpus::next()
{
    document doc{doc_id{cur_}, docs_[cur_].second};

    if (!filesystem::file_exists(prefix_ + docs_[cur_].first))
        throw corpus_exception{"file \"" + docs_[cur_].first
                               + "\" does not exist"};

    doc.content(filesystem::file_text(prefix_ + docs_[cur_].first), encoding());

    auto mdata = next_metadata();
    if (store_full_text())
        mdata.insert(mdata.begin(), metadata::field{doc.content()});

    // add "path" metadata manually
    mdata.insert(mdata.begin(), metadata::field{prefix_ + docs_[cur_].first});
    doc.mdata(std::move(mdata));

    ++cur_;
    return doc;
}
コード例 #29
0
tizgraph_ptr_t graphmgr::dirblemgrops::get_graph (
    const std::string & /* uri */)
{
  tizgraph_ptr_t g_ptr;
  std::string encoding ("pcm");
  tizgraph_ptr_map_t::const_iterator it = graph_registry_.find (encoding);
  if (it == graph_registry_.end ())
  {
    g_ptr = boost::make_shared< tiz::graph::dirble >();
    if (g_ptr)
    {
      // TODO: Check rc
      std::pair< tizgraph_ptr_map_t::iterator, bool > rc
          = graph_registry_.insert (
              std::make_pair< std::string, tizgraph_ptr_t >(encoding, g_ptr));
      if (rc.second)
      {
        // TODO: Check rc
        g_ptr->init ();
        g_ptr->set_manager (p_mgr_);
      }
      else
      {
        GMGR_OPS_RECORD_ERROR (OMX_ErrorInsufficientResources,
                               "Unable to register a new graph.");
      }
    }
    else
    {
      GMGR_OPS_RECORD_ERROR (OMX_ErrorInsufficientResources,
                             "Unable to create the Dirble client graph.");
    }
  }
  else
  {
    g_ptr = it->second;
  }

  return g_ptr;
}
コード例 #30
0
int CBlastHitMatrixCGIApplication::ProcessRequest(CCgiContext &ctx)
{
    // retrieve our CGI rendering params
    x_GetCGIContextParams(ctx);            
    x_InitAppData(ctx);        
        
    bool success = true;       
    if(m_BlastHitMatrix->IsFileOut()) {
        success = m_BlastHitMatrix->WriteToFile();
    }
    else {        
        string encoding("image/png");
        CCgiResponse& response = ctx.GetResponse();
        response.SetContentType(encoding);
        response.WriteHeader();        
        success = m_BlastHitMatrix->Display(response.out());
    }
    if(!success) {
        NCBI_THROW(CBlastHitMatrixCGIException, eImageRenderError, "Exception occured, exception message: " + m_BlastHitMatrix->GetErrorMessage()); 
    }
    return 0;
}