From 7aebeeb2e2ad13c89c202d0bfa8c634ab27b91b4 Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Sat, 23 Nov 2013 09:25:38 +0100 Subject: Do not throw exception for normal code flow (exceptions::no_such_parameter). --- src/contentTypeField.cpp | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) (limited to 'src/contentTypeField.cpp') diff --git a/src/contentTypeField.cpp b/src/contentTypeField.cpp index c67654a5..9f38294a 100644 --- a/src/contentTypeField.cpp +++ b/src/contentTypeField.cpp @@ -40,9 +40,20 @@ contentTypeField::contentTypeField(contentTypeField&) } +bool contentTypeField::hasBoundary() const +{ + return findParameter("boundary"); +} + + const string contentTypeField::getBoundary() const { - return findParameter("boundary")->getValue().getBuffer(); + shared_ptr param = findParameter("boundary"); + + if (param) + return param->getValue().getBuffer(); + else + return ""; } @@ -52,9 +63,20 @@ void contentTypeField::setBoundary(const string& boundary) } +bool contentTypeField::hasCharset() const +{ + return findParameter("charset"); +} + + const charset contentTypeField::getCharset() const { - return findParameter("charset")->getValueAs (); + shared_ptr param = findParameter("charset"); + + if (param) + return param->getValueAs (); + else + return charset(); } @@ -64,9 +86,20 @@ void contentTypeField::setCharset(const charset& ch) } +bool contentTypeField::hasReportType() const +{ + return findParameter("report-type"); +} + + const string contentTypeField::getReportType() const { - return findParameter("report-type")->getValue().getBuffer(); + shared_ptr param = findParameter("report-type"); + + if (param) + return param->getValue().getBuffer(); + else + return ""; } -- cgit v1.2.3