コード例 #1
0
ファイル: TcpClient.cpp プロジェクト: colinsullivan/stk
int TcpClient :: readBuffer( void *buffer, long bufferSize, int flags )
{
  if ( !isValid( soket_ ) ) return -1;
  return recv( soket_, (char *)buffer, bufferSize, flags );
}
コード例 #2
0
 inline Real SimpleQuote::value() const {
     QL_ENSURE(isValid(), "invalid SimpleQuote");
     return value_;
 }
コード例 #3
0
ファイル: AVPacketSampleBuffer.cpp プロジェクト: zangel/uquad
system::error_code AVPacketSampleBuffer::unlock()
{
    return base::makeErrorCode(isValid() ? base::kENoError : base::kEInvalidContent);
}
コード例 #4
0
void LevelDBTransaction::TreeIterator::reset()
{
    ASSERT(isValid());
    m_iterator.start_iter(*m_tree, m_key, TreeType::EQUAL);
    ASSERT(isValid());
}
コード例 #5
0
ファイル: time.hpp プロジェクト: cfillion/reapack
 operator bool() const { return isValid(); }
コード例 #6
0
void LevelDBTransaction::TreeIterator::seekToLast()
{
    m_iterator.start_iter_greatest(*m_tree);
    if (isValid())
        m_key = (*m_iterator)->key;
}
コード例 #7
0
LevelDBSlice LevelDBTransaction::TreeIterator::value() const
{
    ASSERT(isValid());
    ASSERT(!isDeleted());
    return (*m_iterator)->value;
}
コード例 #8
0
ファイル: gtm.cpp プロジェクト: 469447793/World-Wind-Java
bool GTM::isValid()
{
    //  2 bytes - version number
    // 10 bytes - "TrackMaker" string
    char buffer[13];

    char* szHeader;
    short version;

/* -------------------------------------------------------------------- */
/*      If we aren't sure it is GTM, load a header chunk and check      */
/*      for signs it is GTM                                             */
/* -------------------------------------------------------------------- */
    size_t nRead = VSIFReadL( buffer, 1, sizeof(buffer)-1, pGTMFile );
    if (nRead <= 0)
    {
        VSIFCloseL( pGTMFile );
        pGTMFile = NULL;
        return FALSE;
    }
    buffer[12] = '\0';
    
/* -------------------------------------------------------------------- */
/*      If it looks like a GZip header, this may be a .gtz file, so     */
/*      try opening with the /vsigzip/ prefix                           */
/* -------------------------------------------------------------------- */
    if (buffer[0] == 0x1f && ((unsigned char*)buffer)[1] == 0x8b &&
        strncmp(pszFilename, "/vsigzip/", strlen("/vsigzip/")) != 0)
    {
        char* pszGZIPFileName = (char*)CPLMalloc(
                           strlen("/vsigzip/") + strlen(pszFilename) + 1);
        sprintf(pszGZIPFileName, "/vsigzip/%s", pszFilename);
        FILE* fp = VSIFOpenL(pszGZIPFileName, "rb");
        if (fp)
        {
            FILE* pGTMFileOri = pGTMFile;
            pGTMFile = fp;
            if (isValid())
            {
                VSIFCloseL(pGTMFileOri);
                return TRUE;
            }
            else
            {
                if (pGTMFile)
                    VSIFCloseL(pGTMFile);
                pGTMFile = pGTMFileOri;
            }
        }
        CPLFree(pszGZIPFileName);
    }
    
    version = CPL_LSBINT16PTR(buffer);
    /*Skip string length */
    szHeader = buffer + 2;
    if (version == 211 && strcmp(szHeader, "TrackMaker") == 0 )
    {
        return TRUE;
    }
    return FALSE;
}
コード例 #9
0
ファイル: UdpSocket.cpp プロジェクト: colinsullivan/stk
int UdpSocket :: writeBuffer( const void *buffer, long bufferSize, int flags )
{
  if ( !isValid( soket_ ) || !validAddress_ ) return -1;
  return sendto( soket_, (const char *)buffer, bufferSize, flags, (struct sockaddr *)&address_, sizeof(address_) );
}
コード例 #10
0
void LightDriver_Destroy(LightDriver self)
{
    if (isValid(self))
        interface->Destroy(self);
}
コード例 #11
0
void LightDriver_SetBrightness(LightDriver self, int level)
{
    if(isValid(self) && self->brightness)
        self->brightness(self, level);
}
コード例 #12
0
void LightDriver_TurnOff(LightDriver self)
{
    if (isValid(self))
        interface->TurnOff(self);
}
コード例 #13
0
ファイル: axFile.cpp プロジェクト: Jasonchan35/libax
axStatus axFile::setPosEnd	( axFileSize  n ) {
	if( ! isValid() ) { assert(false);	return axStatus_Std::not_initialized; }	
	off_t ret = lseek( h_, n, SEEK_END );
	if( ret == -1 ) return axStatus_Std::File_seek_error;
	return 0;
}
コード例 #14
0
ファイル: CSSFontFaceSource.cpp プロジェクト: acss/owb-mirror
SimpleFontData* CSSFontFaceSource::getFontData(const FontDescription& fontDescription, bool syntheticBold, bool syntheticItalic, CSSFontSelector* fontSelector)
{
    // If the font hasn't loaded or an error occurred, then we've got nothing.
    if (!isValid())
        return 0;

#if ENABLE(SVG_FONTS)
    if (!m_font && !m_svgFontFaceElement) {
#else
    if (!m_font) {
#endif
        FontPlatformData* data = FontCache::getCachedFontPlatformData(fontDescription, m_string);
        SimpleFontData* fontData = FontCache::getCachedFontData(data);

        // We're local. Just return a SimpleFontData from the normal cache.
        return fontData;
    }

    // See if we have a mapping in our FontData cache.
    unsigned hashKey = fontDescription.computedPixelSize() << 2 | (syntheticBold ? 2 : 0) | (syntheticItalic ? 1 : 0);
    if (SimpleFontData* cachedData = m_fontDataTable.get(hashKey))
        return cachedData;

    OwnPtr<SimpleFontData> fontData;

    // If we are still loading, then we let the system pick a font.
    if (isLoaded()) {
        if (m_font) {
#if ENABLE(SVG_FONTS)
            if (m_font->isSVGFont()) {
                // For SVG fonts parse the external SVG document, and extract the <font> element.
                if (!m_font->ensureSVGFontData())
                    return 0;

                if (!m_externalSVGFontElement)
                    m_externalSVGFontElement = m_font->getSVGFontById(SVGURIReference::getTarget(m_string));

                if (!m_externalSVGFontElement)
                    return 0;

                SVGFontFaceElement* fontFaceElement = 0;

                // Select first <font-face> child
                for (Node* fontChild = m_externalSVGFontElement->firstChild(); fontChild; fontChild = fontChild->nextSibling()) {
                    if (fontChild->hasTagName(SVGNames::font_faceTag)) {
                        fontFaceElement = static_cast<SVGFontFaceElement*>(fontChild);
                        break;
                    }
                }

                if (fontFaceElement) {
                    if (!m_svgFontFaceElement) {
                        // We're created using a CSS @font-face rule, that means we're not associated with a SVGFontFaceElement.
                        // Use the imported <font-face> tag as referencing font-face element for these cases.
                        m_svgFontFaceElement = fontFaceElement;
                    }

                    SVGFontData* svgFontData = new SVGFontData(fontFaceElement);
                    fontData.set(new SimpleFontData(m_font->platformDataFromCustomData(fontDescription.computedPixelSize(), syntheticBold, syntheticItalic, fontDescription.renderingMode()), true, false, svgFontData));
                }
            } else
#endif
            {
                // Create new FontPlatformData from our CGFontRef, point size and ATSFontRef.
                if (!m_font->ensureCustomFontData())
                    return 0;

                fontData.set(new SimpleFontData(m_font->platformDataFromCustomData(fontDescription.computedPixelSize(), syntheticBold, syntheticItalic, fontDescription.renderingMode()), true, false));
            }
        } else {
#if ENABLE(SVG_FONTS)
            // In-Document SVG Fonts
            if (m_svgFontFaceElement) {
                SVGFontData* svgFontData = new SVGFontData(m_svgFontFaceElement.get());
                fontData.set(new SimpleFontData(FontPlatformData(fontDescription.computedPixelSize(), syntheticBold, syntheticItalic), true, false, svgFontData));
            }
#endif
        }
    } else {
        // Kick off the load now.
        if (DocLoader* docLoader = fontSelector->docLoader())
            m_font->beginLoadIfNeeded(docLoader);
        // FIXME: m_string is a URL so it makes no sense to pass it as a family name.
        FontPlatformData* tempData = FontCache::getCachedFontPlatformData(fontDescription, m_string);
        if (!tempData)
            tempData = FontCache::getLastResortFallbackFont(fontDescription);
        fontData.set(new SimpleFontData(*tempData, true, true));
    }

    m_fontDataTable.set(hashKey, fontData.get());
    return fontData.release();
}

}
コード例 #15
0
//! Draw the slider into the specified rectangle.
void QwtSlider::drawSlider(QPainter *p, const QRect &r)
{
    QRect cr(r);

    if (d_data->bgStyle & BgTrough)
    {
        qDrawShadePanel(p, r.x(), r.y(),
                        r.width(), r.height(),
#if QT_VERSION < 0x040000
                        colorGroup(),
#else
                        palette(),
#endif
                        true, d_data->borderWidth,0);

        cr.setRect(r.x() + d_data->borderWidth,
                   r.y() + d_data->borderWidth,
                   r.width() - 2 * d_data->borderWidth,
                   r.height() - 2 * d_data->borderWidth);

        p->fillRect(cr.x(), cr.y(), cr.width(), cr.height(),
#if QT_VERSION < 0x040000
                    colorGroup().brush(QColorGroup::Mid)
#else
                    palette().brush(QPalette::Mid)
#endif
                   );
    }

    if ( d_data->bgStyle & BgSlot)
    {
        int ws = 4;
        int ds = d_data->thumbLength / 2 - 4;
        if ( ds < 1 )
            ds = 1;

        QRect rSlot;
        if (orientation() == Qt::Horizontal)
        {
            if ( cr.height() & 1 )
                ws++;
            rSlot = QRect(cr.x() + ds,
                          cr.y() + (cr.height() - ws) / 2,
                          cr.width() - 2 * ds, ws);
        }
        else
        {
            if ( cr.width() & 1 )
                ws++;
            rSlot = QRect(cr.x() + (cr.width() - ws) / 2,
                          cr.y() + ds,
                          ws, cr.height() - 2 * ds);
        }
        p->fillRect(rSlot.x(), rSlot.y(), rSlot.width(), rSlot.height(),
#if QT_VERSION < 0x040000
                    colorGroup().brush(QColorGroup::Dark)
#else
                    palette().brush(QPalette::Dark)
#endif
                   );
        qDrawShadePanel(p, rSlot.x(), rSlot.y(),
                        rSlot.width(), rSlot.height(),
#if QT_VERSION < 0x040000
                        colorGroup(),
#else
                        palette(),
#endif
                        true, 1 ,0);

    }

    if ( isValid() )
        drawThumb(p, cr, xyPosition(value()));
}
コード例 #16
0
ファイル: UdpSocket.cpp プロジェクト: colinsullivan/stk
int UdpSocket :: readBuffer( void *buffer, long bufferSize, int flags )
{
  if ( !isValid( soket_ ) ) return -1;
  return recvfrom( soket_, (char *)buffer, bufferSize, flags, NULL, NULL );
}
コード例 #17
0
PassRefPtr<SimpleFontData> CSSFontFaceSource::getFontData(const FontDescription& fontDescription)
{
    // If the font hasn't loaded or an error occurred, then we've got nothing.
    if (!isValid())
        return 0;

    if (isLocal()) {
        // We're local. Just return a SimpleFontData from the normal cache.
        // We don't want to check alternate font family names here, so pass true as the checkingAlternateName parameter.
        RefPtr<SimpleFontData> fontData = FontCache::fontCache()->getFontData(fontDescription, m_string, true);
        m_histograms.recordLocalFont(fontData);
        return fontData;
    }

    // See if we have a mapping in our FontData cache.
    AtomicString emptyFontFamily = "";
    FontCacheKey key = fontDescription.cacheKey(emptyFontFamily);

    RefPtr<SimpleFontData>& fontData = m_fontDataTable.add(key.hash(), 0).storedValue->value;
    if (fontData)
        return fontData; // No release, because fontData is a reference to a RefPtr that is held in the m_fontDataTable.

    // If we are still loading, then we let the system pick a font.
    if (isLoaded()) {
        if (m_font) {
#if ENABLE(SVG_FONTS)
            if (m_hasExternalSVGFont) {
                // For SVG fonts parse the external SVG document, and extract the <font> element.
                if (!m_font->ensureSVGFontData())
                    return 0;

                if (!m_externalSVGFontElement) {
                    String fragmentIdentifier;
                    size_t start = m_string.find('#');
                    if (start != kNotFound)
                        fragmentIdentifier = m_string.string().substring(start + 1);
                    m_externalSVGFontElement = m_font->getSVGFontById(fragmentIdentifier);
                }

                if (!m_externalSVGFontElement)
                    return 0;

                SVGFontFaceElement* fontFaceElement = 0;

                // Select first <font-face> child
                for (Node* fontChild = m_externalSVGFontElement->firstChild(); fontChild; fontChild = fontChild->nextSibling()) {
                    if (fontChild->hasTagName(SVGNames::font_faceTag)) {
                        fontFaceElement = toSVGFontFaceElement(fontChild);
                        break;
                    }
                }

                if (fontFaceElement) {
                    if (!m_svgFontFaceElement) {
                        // We're created using a CSS @font-face rule, that means we're not associated with a SVGFontFaceElement.
                        // Use the imported <font-face> tag as referencing font-face element for these cases.
                        m_svgFontFaceElement = fontFaceElement;
                    }

                    fontData = SimpleFontData::create(
                        SVGFontData::create(fontFaceElement),
                        fontDescription.effectiveFontSize(),
                        fontDescription.isSyntheticBold(),
                        fontDescription.isSyntheticItalic());
                }
            } else
#endif
            {
                // Create new FontPlatformData from our CGFontRef, point size and ATSFontRef.
                if (!m_font->ensureCustomFontData())
                    return 0;

                fontData = SimpleFontData::create(
                    m_font->platformDataFromCustomData(fontDescription.effectiveFontSize(),
                        fontDescription.isSyntheticBold(), fontDescription.isSyntheticItalic(),
                        fontDescription.orientation(), fontDescription.widthVariant()), CustomFontData::create(false));
            }
        } else {
#if ENABLE(SVG_FONTS)
            // In-Document SVG Fonts
            if (m_svgFontFaceElement) {
                fontData = SimpleFontData::create(
                    SVGFontData::create(m_svgFontFaceElement.get()),
                    fontDescription.effectiveFontSize(),
                    fontDescription.isSyntheticBold(),
                    fontDescription.isSyntheticItalic());
            }
#endif
        }
    } else {
        // This temporary font is not retained and should not be returned.
        FontCachePurgePreventer fontCachePurgePreventer;
        SimpleFontData* temporaryFont = FontCache::fontCache()->getNonRetainedLastResortFallbackFont(fontDescription);
        if (!temporaryFont) {
            ASSERT_NOT_REACHED();
            return 0;
        }
        RefPtr<CSSCustomFontData> cssFontData = CSSCustomFontData::create(true);
        cssFontData->setCSSFontFaceSource(this);
        fontData = SimpleFontData::create(temporaryFont->platformData(), cssFontData);
    }

    return fontData; // No release, because fontData is a reference to a RefPtr that is held in the m_fontDataTable.
}
コード例 #18
0
void IteratorImpl::next()
{
    ASSERT(isValid());
    m_iterator->Next();
    checkStatus();
}
コード例 #19
0
LevelDBSlice LevelDBTransaction::TreeIterator::key() const
{
    ASSERT(isValid());
    return m_key;
}
コード例 #20
0
void IteratorImpl::prev()
{
    ASSERT(isValid());
    m_iterator->Prev();
    checkStatus();
}
コード例 #21
0
bool LevelDBTransaction::TreeIterator::isDeleted() const
{
    ASSERT(isValid());
    return (*m_iterator)->deleted;
}
コード例 #22
0
LevelDBSlice IteratorImpl::value() const
{
    ASSERT(isValid());
    return makeLevelDBSlice(m_iterator->value());
}
コード例 #23
0
int ThinBlockBuilder::numTxsMissing() const {
    assert(isValid());
    return missing;
}
コード例 #24
0
void* QVGPixmapData::toNativeType(NativeType type)
{
    if (type == QPixmapData::SgImage) {
#if defined(QT_SYMBIAN_SUPPORTS_SGIMAGE) && !defined(QT_NO_EGL)
        toVGImage();

        if (!isValid() || vgImage == VG_INVALID_HANDLE)
            return 0;

        TInt err = 0;

        RSgDriver driver;
        err = driver.Open();
        if (err != KErrNone)
            return 0;

        TSgImageInfo sgInfo;
        sgInfo.iPixelFormat = EUidPixelFormatARGB_8888_PRE;
        sgInfo.iSizeInPixels.SetSize(w, h);
        sgInfo.iUsage = ESgUsageBitOpenVgImage | ESgUsageBitOpenVgSurface;

        RSgImage *sgImage = q_check_ptr(new RSgImage());
        err = sgImage->Create(sgInfo, NULL, NULL);
        if (err != KErrNone) {
            driver.Close();
            return 0;
        }

        pfnVgCreateEGLImageTargetKHR vgCreateEGLImageTargetKHR = (pfnVgCreateEGLImageTargetKHR) eglGetProcAddress("vgCreateEGLImageTargetKHR");

        if (eglGetError() != EGL_SUCCESS || !(QEgl::hasExtension("EGL_KHR_image") || QEgl::hasExtension("EGL_KHR_image_pixmap")) || !vgCreateEGLImageTargetKHR) {
            driver.Close();
            return 0;
        }

        const EGLint KEglImageAttribs[] = {EGL_IMAGE_PRESERVED_SYMBIAN, EGL_TRUE, EGL_NONE};
        EGLImageKHR eglImage = QEgl::eglCreateImageKHR(QEgl::display(),
                EGL_NO_CONTEXT,
                EGL_NATIVE_PIXMAP_KHR,
                (EGLClientBuffer)sgImage,
                (EGLint*)KEglImageAttribs);
        if (eglGetError() != EGL_SUCCESS) {
            sgImage->Close();
            driver.Close();
            return 0;
        }

        VGImage dstVgImage = vgCreateEGLImageTargetKHR(eglImage);
        if (vgGetError() != VG_NO_ERROR) {
            QEgl::eglDestroyImageKHR(QEgl::display(), eglImage);
            sgImage->Close();
            driver.Close();
            return 0;
        }

        vgCopyImage(dstVgImage, 0, 0,
                vgImage, 0, 0,
                w, h, VG_FALSE);

        if (vgGetError() != VG_NO_ERROR) {
            sgImage->Close();
            sgImage = 0;
        }
        // release stuff
        vgDestroyImage(dstVgImage);
        QEgl::eglDestroyImageKHR(QEgl::display(), eglImage);
        driver.Close();
        return reinterpret_cast<void*>(sgImage);
#endif
    } else if (type == QPixmapData::FbsBitmap) {
        CFbsBitmap *bitmap = q_check_ptr(new CFbsBitmap);

        if (bitmap) {
            if (bitmap->Create(TSize(source.width(), source.height()),
                              EColor16MAP) == KErrNone) {
                const uchar *sptr = source.constBits();
                bitmap->BeginDataAccess();

                uchar *dptr = (uchar*)bitmap->DataAddress();
                Mem::Copy(dptr, sptr, source.byteCount());

                bitmap->EndDataAccess();
            } else {
                delete bitmap;
                bitmap = 0;
            }
        }

        return reinterpret_cast<void*>(bitmap);
    }
    return 0;
}
コード例 #25
0
bool RazorPluginInfo::load(const QString& fileName)
{
    XdgDesktopFile::load(fileName);
    mId = QFileInfo(fileName).completeBaseName();
    return isValid();
}
コード例 #26
0
ファイル: sinput.cpp プロジェクト: dhirajkhatiwada1/uludag
QString SinkInput::getProperty(QString key)
{
    cerr << "getProperty " << key.toStdString() << endl;
    cerr << " in stream " << index() << " valid " << isValid() << endl;
    return QString(pa_proplist_gets(d->proplist, key.toUtf8().data()));
}
コード例 #27
0
 // IPriorityQueueNodePtr implementation
 virtual const PriorityQueueNode<_T, _Priority> & getNode() const {
     if (!isValid()) {
         throw std::runtime_error("binomial heap node pointer is expired");
     }
     return *parent_->nodePtrs_.find(id_)->second.lock();
 }
コード例 #28
0
ファイル: Socket.cpp プロジェクト: linzhenhua/src
TCPSocket::~TCPSocket()
{
    if (isValid())
        ::close(m_sockfd);
}
コード例 #29
0
ファイル: SVG.cpp プロジェクト: eile/Tide
QSize SVG::getSize() const
{
    return isValid() ? _impl->svg->getSize() : QSize();
}
コード例 #30
0
ファイル: TcpClient.cpp プロジェクト: colinsullivan/stk
int TcpClient :: writeBuffer( const void *buffer, long bufferSize, int flags )
{
  if ( !isValid( soket_ ) ) return -1;
  return send( soket_, (const char *)buffer, bufferSize, flags );
}