aboutsummaryrefslogtreecommitdiffstats
path: root/staging_vespalib/src/vespa/vespalib/objects/serializer.hpp
blob: e428be5a348cdd19ef17f0d45c9ae9e7ce790c25 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include <vespa/vespalib/objects/fieldbase.h>
#include <vespa/vespalib/util/array.h>
#include <vector>
#include <stdint.h>

namespace vespalib {

template <typename T>
Serializer &
Serializer::operator << (const vespalib::Array<T> & v) {
    uint32_t sz(v.size());
    put(_sizeField, sz);
    for(size_t i(0); i < sz; i++) {
        (*this) << v[i];
    }
    return *this;
}
template <typename T>
Serializer &
Serializer::operator << (const std::vector<T> & v) {
    uint32_t sz(v.size());
    put(_sizeField, sz);
    for(size_t i(0); i < sz; i++) {
        (*this) << v[i];
    }
    return *this;
}

}