summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Tardon <dtardon@redhat.com>2014-07-13 19:20:37 +0200
committerDavid Tardon <dtardon@redhat.com>2014-07-13 19:20:59 +0200
commitf5ad1320e3b55936947fc1cbac0892dcf0467021 (patch)
treec006a58de720a86b6d026ac29b0a5bfd51475605 /src
parent5b880a63d15fb895c1a302d7a41e91945390ce90 (diff)
bool as result is enough
Diffstat (limited to 'src')
-rw-r--r--src/conv/html/sdf2html.cpp7
-rw-r--r--src/conv/raw/sdf2raw.cpp6
-rw-r--r--src/conv/text/sdf2text.cpp7
-rw-r--r--src/lib/SDFDocument.cpp56
4 files changed, 15 insertions, 61 deletions
diff --git a/src/conv/html/sdf2html.cpp b/src/conv/html/sdf2html.cpp
index e95c70b..3b5c99c 100644
--- a/src/conv/html/sdf2html.cpp
+++ b/src/conv/html/sdf2html.cpp
@@ -75,16 +75,13 @@ int main(int argc, char *argv[])
boost::shared_ptr<librevenge::RVNGInputStream> input(new librevenge::RVNGFileStream(szInputFile));
- SDFDocument::Type type = SDFDocument::TYPE_UNKNOWN;
- SDFDocument::Confidence confidence = SDFDocument::isSupported(input.get(), &type);
-
- if ((SDFDocument::CONFIDENCE_EXCELLENT != confidence) && (SDFDocument::CONFIDENCE_WEAK != confidence))
+ if (!SDFDocument::isSupported(input.get()))
return 1;
librevenge::RVNGString document;
librevenge::RVNGTextTextGenerator documentGenerator(document, isInfo);
- if (SDFDocument::RESULT_OK != SDFDocument::parse(input.get(), &documentGenerator, type))
+ if (!SDFDocument::parse(input.get(), &documentGenerator))
return 1;
printf("%s", document.cstr());
diff --git a/src/conv/raw/sdf2raw.cpp b/src/conv/raw/sdf2raw.cpp
index e68ebf8..d42675f 100644
--- a/src/conv/raw/sdf2raw.cpp
+++ b/src/conv/raw/sdf2raw.cpp
@@ -75,12 +75,12 @@ int main(int argc, char *argv[])
boost::shared_ptr<librevenge::RVNGInputStream> input(new librevenge::RVNGFileStream(file));
- SDFDocument::Type type = SDFDocument::TYPE_UNKNOWN;
- SDFDocument::Confidence confidence = SDFDocument::isSupported(input.get(), &type);
+ if (!SDFDocument::isSupported(input.get()))
+ return 1;
librevenge::RVNGRawTextGenerator documentGenerator(printIndentLevel);
- return (SDFDocument::RESULT_OK == SDFDocument::parse(input.get(), &documentGenerator, type)) ? 0 : 1;
+ return SDFDocument::parse(input.get(), &documentGenerator) ? 0 : 1;
}
/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
diff --git a/src/conv/text/sdf2text.cpp b/src/conv/text/sdf2text.cpp
index 2d1aaa6..937c3f2 100644
--- a/src/conv/text/sdf2text.cpp
+++ b/src/conv/text/sdf2text.cpp
@@ -75,16 +75,13 @@ int main(int argc, char *argv[])
boost::shared_ptr<librevenge::RVNGInputStream> input(new librevenge::RVNGFileStream(szInputFile));
- SDFDocument::Type type = SDFDocument::TYPE_UNKNOWN;
- SDFDocument::Confidence confidence = SDFDocument::isSupported(input.get(), &type);
-
- if ((SDFDocument::CONFIDENCE_EXCELLENT != confidence) && (SDFDocument::CONFIDENCE_WEAK != confidence))
+ if (!SDFDocument::isSupported(input.get()))
return 1;
librevenge::RVNGString document;
librevenge::RVNGTextTextGenerator documentGenerator(document, isInfo);
- if (SDFDocument::RESULT_OK != SDFDocument::parse(input.get(), &documentGenerator, type))
+ if (!SDFDocument::parse(input.get(), &documentGenerator))
return 1;
printf("%s", document.cstr());
diff --git a/src/lib/SDFDocument.cpp b/src/lib/SDFDocument.cpp
index 2e93d42..867f179 100644
--- a/src/lib/SDFDocument.cpp
+++ b/src/lib/SDFDocument.cpp
@@ -29,69 +29,29 @@ using std::equal;
namespace libsdf
{
-SDFAPI SDFDocument::Confidence SDFDocument::isSupported(librevenge::RVNGInputStream *const input, Type *const type) try
+SDFAPI bool SDFDocument::isSupported(librevenge::RVNGInputStream *const input) try
{
- if (type)
- *type = TYPE_UNKNOWN;
-
- return CONFIDENCE_NONE;
+ return false;
}
catch (...)
{
- return CONFIDENCE_NONE;
-}
-
-SDFAPI SDFDocument::Result SDFDocument::parse(librevenge::RVNGInputStream *const input, librevenge::RVNGTextInterface *const document, const char *const)
-{
- Type type;
- Confidence confidence = isSupported(input, &type);
- if (CONFIDENCE_NONE == confidence)
- return RESULT_UNSUPPORTED_FORMAT;
- else if (CONFIDENCE_SUPPORTED_PART == confidence)
- return RESULT_UNSUPPORTED_FORMAT;
- else if (CONFIDENCE_UNSUPPORTED_ENCRYPTION == confidence)
- return RESULT_UNSUPPORTED_ENCRYPTION;
-
- return parse(input, document, type);
+ return false;
}
-SDFAPI SDFDocument::Result SDFDocument::parse(librevenge::RVNGInputStream *const input, librevenge::RVNGTextInterface *const document, const SDFDocument::Type type, const char *const) try
+SDFAPI bool SDFDocument::parse(librevenge::RVNGInputStream *const input, librevenge::RVNGTextInterface *const document) try
{
- // sanity check
- if (SDFDocument::TYPE_UNKNOWN == type)
- return SDFDocument::RESULT_UNSUPPORTED_FORMAT;
- if (SDFDocument::TYPE_RESERVED1 <= type)
- return SDFDocument::RESULT_UNSUPPORTED_FORMAT;
+ if (!isSupported(input))
+ return false;
const RVNGInputStreamPtr_t input_(input, SDFDummyDeleter());
input_->seek(0, librevenge::RVNG_SEEK_SET);
- return RESULT_UNKNOWN_ERROR;
-}
-catch (const FileAccessError &)
-{
- return RESULT_FILE_ACCESS_ERROR;
-}
-catch (const PackageError &)
-{
- return RESULT_PACKAGE_ERROR;
-}
-catch (const PasswordMismatch &)
-{
- return RESULT_PASSWORD_MISMATCH;
-}
-catch (const UnsupportedEncryption &)
-{
- return RESULT_UNSUPPORTED_ENCRYPTION;
-}
-catch (const UnsupportedFormat &)
-{
- return RESULT_UNSUPPORTED_FORMAT;
+ return false;
}
catch (...)
{
- return RESULT_UNKNOWN_ERROR;
+ return false;
}
} // namespace libsdf