qt6windows7/examples/corelib/serialization/convert/nullconverter.cpp

57 lines
1.2 KiB
C++
Raw Normal View History

2023-10-30 06:33:08 +08:00
// Copyright (C) 2018 Intel Corporation.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "nullconverter.h"
2023-11-02 01:02:52 +08:00
using namespace Qt::StringLiterals;
2023-10-30 06:33:08 +08:00
static NullConverter nullConverter;
2023-11-02 01:02:52 +08:00
Converter *Converter::null = &nullConverter;
2023-10-30 06:33:08 +08:00
2023-11-02 01:02:52 +08:00
QString NullConverter::name() const
2023-10-30 06:33:08 +08:00
{
2023-11-02 01:02:52 +08:00
return "null"_L1;
2023-10-30 06:33:08 +08:00
}
2023-11-02 01:02:52 +08:00
Converter::Directions NullConverter::directions() const
2023-10-30 06:33:08 +08:00
{
2023-11-02 01:02:52 +08:00
return Direction::Out;
2023-10-30 06:33:08 +08:00
}
2023-11-02 01:02:52 +08:00
Converter::Options NullConverter::outputOptions() const
2023-10-30 06:33:08 +08:00
{
return SupportsArbitraryMapKeys;
}
2023-11-02 01:02:52 +08:00
const char *NullConverter::optionsHelp() const
2023-10-30 06:33:08 +08:00
{
return nullptr;
}
2023-11-02 01:02:52 +08:00
bool NullConverter::probeFile(QIODevice *f) const
2023-10-30 06:33:08 +08:00
{
Q_UNUSED(f);
return false;
}
2023-11-02 01:02:52 +08:00
QVariant NullConverter::loadFile(QIODevice *f, const Converter *&outputConverter) const
2023-10-30 06:33:08 +08:00
{
Q_UNUSED(f);
Q_UNUSED(outputConverter);
outputConverter = this;
return QVariant();
}
2023-11-02 01:02:52 +08:00
void NullConverter::saveFile(QIODevice *f, const QVariant &contents,
const QStringList &options) const
2023-10-30 06:33:08 +08:00
{
if (!options.isEmpty()) {
2023-11-02 01:02:52 +08:00
fprintf(stderr, "Unknown option '%s' to null output. This format has no options.\n",
qPrintable(options.first()));
2023-10-30 06:33:08 +08:00
exit(EXIT_FAILURE);
}
Q_UNUSED(f);
Q_UNUSED(contents);
}