Odil
A C++11 library for the DICOM standard
Loading...
Searching...
No Matches
Message.h
Go to the documentation of this file.
1/*************************************************************************
2 * odil - Copyright (C) Universite de Strasbourg
3 * Distributed under the terms of the CeCILL-B license, as published by
4 * the CEA-CNRS-INRIA. Refer to the LICENSE file or to
5 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
6 * for details.
7 ************************************************************************/
8
9#ifndef _d7a272d7_9beb_43c1_a5a1_fce4c0245c80
10#define _d7a272d7_9beb_43c1_a5a1_fce4c0245c80
11
12#include <istream>
13#include <map>
14#include <ostream>
15#include <string>
16
17#include "odil/odil.h"
18
19namespace odil
20{
21
22namespace webservices
23{
24
27{
28public:
30 typedef std::map<std::string, std::string> Headers;
31
37 Message(Headers const & headers={}, std::string const & body="");
38
39 Message(Message const &) = default;
40 Message(Message &&) = default;
41 Message & operator=(Message const &) = default;
42 Message & operator=(Message &&) = default;
43 virtual ~Message() = default;
44
46 Headers const & get_headers() const;
47
49 void set_headers(Headers const & headers);
50
57 bool has_header(std::string const & name) const;
58
66 std::string const & get_header(std::string const & name) const;
67
69 void set_header(std::string const & name, std::string const & value);
70
72 std::string const & get_body() const;
73
75 void set_body(std::string const & body);
76
77private:
78 Headers _headers;
79 std::string _body;
80
81 Headers::const_iterator _find_header(std::string const & name) const;
82};
83
86std::istream &
87operator>>(std::istream & stream, Message & message);
88
91std::ostream &
92operator<<(std::ostream & stream, Message const & message);
93
94}
95
96}
97
98#endif // _d7a272d7_9beb_43c1_a5a1_fce4c0245c80
RFC 5322 Message (i.e. headers with body).
Definition Message.h:27
virtual ~Message()=default
void set_body(std::string const &body)
Set the body.
Message(Message &&)=default
Message(Headers const &headers={}, std::string const &body="")
Constructor.
Message & operator=(Message const &)=default
void set_headers(Headers const &headers)
Set the headers.
bool has_header(std::string const &name) const
Test whether the given header exists.
std::string const & get_body() const
Return the body.
Message & operator=(Message &&)=default
std::map< std::string, std::string > Headers
Associative container for headers.
Definition Message.h:30
std::string const & get_header(std::string const &name) const
Return a header value or throw an exception if the required header is missing.
void set_header(std::string const &name, std::string const &value)
Set a header value.
Message(Message const &)=default
Headers const & get_headers() const
Return the headers.
std::istream & operator>>(std::istream &stream, HTTPRequest &request)
Input an HTTP request from a stream.
std::ostream & operator<<(std::ostream &stream, HTTPRequest const &request)
Output an HTTP request to a stream.
Definition Association.h:25
#define ODIL_API
Definition odil.h:28