本文整理汇总了C++中containers::ArrayView::end方法的典型用法代码示例。如果您正苦于以下问题:C++ ArrayView::end方法的具体用法?C++ ArrayView::end怎么用?C++ ArrayView::end使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类containers::ArrayView
的用法示例。
在下文中一共展示了ArrayView::end方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
std::pair<TweakableState, double> TweakableParser<double>::parse(Containers::ArrayView<const char> value) {
char* end;
const double result = std::strtod(value, &end);
if(end == value.begin() || std::find(value.begin(), value.end(), '.') == value.end()) {
Warning{} << "Utility::TweakableParser:" << std::string{value, value.size()} << "is not a floating-point literal";
return {TweakableState::Recompile, {}};
}
if(end != value.end()) {
Warning{} << "Utility::TweakableParser: unexpected characters" << std::string{const_cast<const char*>(end), value.end()} << "after a floating-point literal";
return {TweakableState::Recompile, {}};
}
return {TweakableState::Success, result};
}
示例2: integerBase
std::pair<TweakableState, unsigned long long> TweakableParser<unsigned long long>::parse(Containers::ArrayView<const char> value) {
const std::pair<const char*, int> valueBase = integerBase(value);
char* end;
const int result = std::strtoull(valueBase.first, &end, valueBase.second);
if(end == value.begin()) {
Warning{} << "Utility::TweakableParser:" << std::string{value, value.size()} << "is not an integer literal";
return {TweakableState::Recompile, {}};
}
if(value.size() < 3 ||
(value[value.size() - 1] != 'l' && value[value.size() - 1] != 'L' &&
value[value.size() - 2] != 'l' && value[value.size() - 2] != 'L' &&
value[value.size() - 2] != 'u' && value[value.size() - 2] != 'U'))
{
Warning{} << "Utility::TweakableParser:" << std::string{value, value.size()} << "has an unexpected suffix, expected ull";
return {TweakableState::Recompile, {}};
}
if(end != value.end() - 3) {
Warning{} << "Utility::TweakableParser: unexpected characters" << std::string{const_cast<const char*>(end), value.end()} << "after an integer literal";
return {TweakableState::Recompile, {}};
}
return {TweakableState::Success, result};
}
示例3: doOpenData
void JpegImporter::doOpenData(const Containers::ArrayView<const char> data) {
/* Because here we're copying the data and using the _in to check if file
is opened, having them nullptr would mean openData() would fail without
any error message. It's not possible to do this check on the importer
side, because empty file is valid in some formats (OBJ or glTF). We also
can't do the full import here because then doImage2D() would need to
copy the imported data instead anyway (and the uncompressed size is much
larger). This way it'll also work nicely with a future openMemory(). */
if(data.empty()) {
Error{} << "Trade::JpegImporter::openData(): the file is empty";
return;
}
_in = Containers::Array<unsigned char>(data.size());
std::copy(data.begin(), data.end(), _in.begin());
}
示例4: doOpenData
void JpegImporter::doOpenData(const Containers::ArrayView<const char> data) {
_in = Containers::Array<unsigned char>(data.size());
std::copy(data.begin(), data.end(), _in.begin());
}
示例5: doOpenData
void WavImporter::doOpenData(Containers::ArrayView<const char> data) {
/* Check file size */
if(data.size() < sizeof(WavHeader)) {
Error() << "Audio::WavImporter::openData(): the file is too short:" << data.size() << "bytes";
return;
}
/* Get header contents and fix endianness */
WavHeader header(*reinterpret_cast<const WavHeader*>(data.begin()));
Utility::Endianness::littleEndianInPlace(header.chunkSize,
header.subChunk1Size, header.audioFormat, header.numChannels,
header.sampleRate, header.byteRate, header.blockAlign,
header.bitsPerSample, header.subChunk2Size);
/* Check file signature */
if(std::strncmp(header.chunkId, "RIFF", 4) != 0 ||
std::strncmp(header.format, "WAVE", 4) != 0 ||
std::strncmp(header.subChunk1Id, "fmt ", 4) != 0 ||
std::strncmp(header.subChunk2Id, "data", 4) != 0) {
Error() << "Audio::WavImporter::openData(): the file signature is invalid";
return;
}
/* Check file size */
if(header.chunkSize + 8 != data.size()) {
Error() << "Audio::WavImporter::openData(): the file has improper size, expected"
<< header.chunkSize + 8 << "but got" << data.size();
return;
}
/* Check PCM format */
if(header.audioFormat != 1) {
Error() << "Audio::WavImporter::openData(): unsupported audio format" << header.audioFormat;
return;
}
/* Verify more things */
if(header.subChunk1Size != 16 ||
header.subChunk2Size + 44 != data.size() ||
header.blockAlign != header.numChannels*header.bitsPerSample/8 ||
header.byteRate != header.sampleRate*header.blockAlign) {
Error() << "Audio::WavImporter::openData(): the file is corrupted";
return;
}
/* Decide about format */
if(header.numChannels == 1 && header.bitsPerSample == 8)
_format = Buffer::Format::Mono8;
else if(header.numChannels == 1 && header.bitsPerSample == 16)
_format = Buffer::Format::Mono16;
else if(header.numChannels == 2 && header.bitsPerSample == 8)
_format = Buffer::Format::Stereo8;
else if(header.numChannels == 2 && header.bitsPerSample == 16)
_format = Buffer::Format::Stereo16;
else {
Error() << "Audio::WavImporter::openData(): unsupported channel count"
<< header.numChannels << "with" << header.bitsPerSample
<< "bits per sample";
return;
}
/* Save frequency */
_frequency = header.sampleRate;
/** @todo Convert the data from little endian too */
CORRADE_INTERNAL_ASSERT(!Utility::Endianness::isBigEndian());
/* Copy the data */
_data = Containers::Array<char>(header.subChunk2Size);
std::copy(data.begin()+sizeof(WavHeader), data.end(), _data.begin());
return;
}
示例6: doOpenData
void TgaImporter::doOpenData(const Containers::ArrayView<const char> data) {
_in = Containers::Array<char>{data.size()};
std::copy(data.begin(), data.end(), _in.begin());
}