1/*
2 * Copyright 2013-2017 Haiku Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 *
5 * Authors:
6 *		Adrien Destugues, pulkomandy@pulkomandy.tk
7 */
8
9
10#include <UrlResult.h>
11
12
13BUrlResult::BUrlResult()
14	:
15	BArchivable(),
16	fContentType(),
17	fLength(0)
18{
19}
20
21
22BUrlResult::BUrlResult(BMessage* archive)
23	:
24	BArchivable(archive)
25{
26	fContentType = archive->FindString("ContentType");
27	fLength = archive->FindInt32("Length");
28}
29
30
31BUrlResult::~BUrlResult()
32{
33}
34
35
36status_t
37BUrlResult::Archive(BMessage* archive, bool deep) const
38{
39	status_t result = BArchivable::Archive(archive, deep);
40
41	if (result != B_OK)
42		return result;
43
44	archive->AddString("ContentType", fContentType);
45	archive->AddInt32("Length", fLength);
46
47	return B_OK;
48}
49
50
51void
52BUrlResult::SetContentType(BString contentType)
53{
54	fContentType = contentType;
55}
56
57
58void
59BUrlResult::SetLength(size_t length)
60{
61	fLength = length;
62}
63
64
65BString
66BUrlResult::ContentType() const
67{
68	return fContentType;
69}
70
71
72size_t
73BUrlResult::Length() const
74{
75	return fLength;
76}
77
78
79/*static*/ BArchivable*
80BUrlResult::Instantiate(BMessage* archive)
81{
82	if (!validate_instantiation(archive, "BUrlResult"))
83		return NULL;
84	return new BUrlResult(archive);
85}
86