コード例 #1
0
size_t SharedBuffer::getSomeDataInternal(const char*& someData,
                                         size_t position) const {
  size_t totalSize = size();
  if (position >= totalSize) {
    someData = 0;
    return 0;
  }

  SECURITY_DCHECK(position < m_size);
  size_t consecutiveSize = m_buffer.size();
  if (position < consecutiveSize) {
    someData = m_buffer.data() + position;
    return consecutiveSize - position;
  }

  position -= consecutiveSize;
  size_t segments = m_segments.size();
  size_t maxSegmentedSize = segments * kSegmentSize;
  size_t segment = segmentIndex(position);
  if (segment < segments) {
    size_t bytesLeft = totalSize - consecutiveSize;
    size_t segmentedSize = std::min(maxSegmentedSize, bytesLeft);

    size_t positionInSegment = offsetInSegment(position);
    someData = m_segments[segment] + positionInSegment;
    return segment == segments - 1 ? segmentedSize - position
                                   : kSegmentSize - positionInSegment;
  }
  ASSERT_NOT_REACHED();
  return 0;
}
コード例 #2
0
unsigned SharedBuffer::getSomeData(const char*& someData, unsigned position) const
{
    if (hasPlatformData() || m_purgeableBuffer) {
        someData = data() + position;
        return size() - position;
    }

    if (position >= m_size) {
        someData = 0;
        return 0;
    }

    unsigned consecutiveSize = m_buffer.size();
    if (position < consecutiveSize) {
        someData = m_buffer.data() + position;
        return consecutiveSize - position;
    }
 
    position -= consecutiveSize;
    unsigned segmentedSize = m_size - consecutiveSize;
    unsigned segments = m_segments.size();
    unsigned segment = segmentIndex(position);
    ASSERT(segment < segments);

    unsigned positionInSegment = offsetInSegment(position);
    someData = m_segments[segment] + positionInSegment;
    return segment == segments - 1 ? segmentedSize - position : segmentSize - positionInSegment;
}
コード例 #3
0
ファイル: SharedBuffer.cpp プロジェクト: aosm/WebCore
unsigned SharedBuffer::getSomeData(const char*& someData, unsigned position) const
{
    unsigned totalSize = size();
    if (position >= totalSize) {
        someData = 0;
        return 0;
    }

#if ENABLE(DISK_IMAGE_CACHE)
    ASSERT(position < size());
    if (isMemoryMapped()) {
        const char* data = static_cast<const char*>(diskImageCache().dataForItem(m_diskImageCacheId));
        someData = data + position;
        return size() - position;
    }
#endif

    if (hasPlatformData() || m_purgeableBuffer) {
        ASSERT_WITH_SECURITY_IMPLICATION(position < size());
        someData = data() + position;
        return totalSize - position;
    }

    ASSERT_WITH_SECURITY_IMPLICATION(position < m_size);
    unsigned consecutiveSize = m_buffer->data.size();
    if (position < consecutiveSize) {
        someData = m_buffer->data.data() + position;
        return consecutiveSize - position;
    }
 
    position -= consecutiveSize;
#if !USE(NETWORK_CFDATA_ARRAY_CALLBACK)
    unsigned segments = m_segments.size();
    unsigned maxSegmentedSize = segments * segmentSize;
    unsigned segment = segmentIndex(position);
    if (segment < segments) {
        unsigned bytesLeft = totalSize - consecutiveSize;
        unsigned segmentedSize = std::min(maxSegmentedSize, bytesLeft);

        unsigned positionInSegment = offsetInSegment(position);
        someData = m_segments[segment] + positionInSegment;
        return segment == segments - 1 ? segmentedSize - position : segmentSize - positionInSegment;
    }
    ASSERT_NOT_REACHED();
    return 0;
#else
    return copySomeDataFromDataArray(someData, position);
#endif
}
コード例 #4
0
ファイル: SharedBuffer.cpp プロジェクト: Moondee/Artemis
unsigned SharedBuffer::getSomeData(const char*& someData, unsigned position) const
{
    unsigned totalSize = size();
    if (position >= totalSize) {
        someData = 0;
        return 0;
    }

    if (hasPlatformData() || m_purgeableBuffer) {
        ASSERT(position < size());
        someData = data() + position;
        return totalSize - position;
    }

    ASSERT(position < m_size);
    unsigned consecutiveSize = m_buffer.size();
    if (position < consecutiveSize) {
        someData = m_buffer.data() + position;
        return consecutiveSize - position;
    }
 
    position -= consecutiveSize;
    unsigned segments = m_segments.size();
    unsigned maxSegmentedSize = segments * segmentSize;
    unsigned segment = segmentIndex(position);
    if (segment < segments) {
        unsigned bytesLeft = totalSize - consecutiveSize;
        unsigned segmentedSize = min(maxSegmentedSize, bytesLeft);

        unsigned positionInSegment = offsetInSegment(position);
        someData = m_segments[segment] + positionInSegment;
        return segment == segments - 1 ? segmentedSize - position : segmentSize - positionInSegment;
    }
#if HAVE(NETWORK_CFDATA_ARRAY_CALLBACK)
    ASSERT(maxSegmentedSize <= position);
    position -= maxSegmentedSize;
    return copySomeDataFromDataArray(someData, position);
#else
    ASSERT_NOT_REACHED();
    return 0;
#endif
}
コード例 #5
0
CapitalisationAlgorithms::CapitalisationAlgorithms()
{
    add({ "Upper", "Capitalisation",
        [](std::string input, std::vector<std::string> /*params*/, bool /*ignoreCase*/, bool /*reverseOutput*/) -> std::string
        {
            return boost::locale::to_upper(input);
        }
    });

    add({ "Lower", "Capitalisation",
        [](std::string input, std::vector<std::string> /*params*/, bool /*ignoreCase*/, bool /*reverseOutput*/) -> std::string
        {
            return boost::locale::to_lower(input);
        }
    });

    add({ "Title", "Capitalisation",
        [](std::string input, std::vector<std::string> /*params*/, bool /*ignoreCase*/, bool /*reverseOutput*/) -> std::string
        {
            return boost::locale::to_title(input);
        }
    });

    add({ "Toggle", "Capitalisation",
        [](std::string input, std::vector<std::string> /*params*/, bool /*ignoreCase*/, bool /*reverseOutput*/) -> std::string
        {
            std::stringstream stream;

            boost::locale::boundary::ssegment_index segmentIndex(boost::locale::boundary::character, std::begin(input), std::end(input));

            for (const auto& segment : segmentIndex)
            {
                stream << (isUpper(segment.str()) ? boost::locale::to_lower(segment.str()) : boost::locale::to_upper(segment.str()));

            }

            return stream.str();
        }
    });
}
コード例 #6
0
ファイル: SharedBuffer.cpp プロジェクト: ddxxyy/webkit
unsigned SharedBuffer::getSomeData(const char*& someData, unsigned position) const
{
    unsigned totalSize = size();
    if (position >= totalSize) {
        someData = 0;
        return 0;
    }

    if (hasPlatformData()) {
        ASSERT_WITH_SECURITY_IMPLICATION(position < size());
        someData = data() + position;
        return totalSize - position;
    }

    ASSERT_WITH_SECURITY_IMPLICATION(position < m_size);
    unsigned consecutiveSize = m_buffer->data.size();
    if (position < consecutiveSize) {
        someData = m_buffer->data.data() + position;
        return consecutiveSize - position;
    }
 
    position -= consecutiveSize;
#if !USE(NETWORK_CFDATA_ARRAY_CALLBACK)
    unsigned segments = m_segments.size();
    unsigned maxSegmentedSize = segments * segmentSize;
    unsigned segment = segmentIndex(position);
    if (segment < segments) {
        unsigned bytesLeft = totalSize - consecutiveSize;
        unsigned segmentedSize = std::min(maxSegmentedSize, bytesLeft);

        unsigned positionInSegment = offsetInSegment(position);
        someData = m_segments[segment] + positionInSegment;
        return segment == segments - 1 ? segmentedSize - position : segmentSize - positionInSegment;
    }
    ASSERT_NOT_REACHED();
    return 0;
#else
    return copySomeDataFromDataArray(someData, position);
#endif
}