-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserialize.cc
45 lines (41 loc) · 1.32 KB
/
serialize.cc
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
34
35
36
37
38
39
40
41
42
43
44
/*
* This is port of OpenHttpStreamer for win32
* copyright (c) 2011 [email protected]
*
* Originally:
* copyright (c) 2010 ZAO Inventos (inventos.ru)
* copyright (c) 2010 [email protected]
* copyright (c) 2010 [email protected]
* copyright (c) 2010 [email protected]
*
* This file is part of mp4frag.
*
* mp4grag is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* mp4frag is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
#include "serialize.hh"
#include <vector>
std::string readstring(std::streambuf *in) {
uint16_t strsz = read16(in);
if ( strsz < 256 ) {
char buffer[256];
in->sgetn(buffer, strsz);
return std::string(buffer, strsz);
}
else {
std::vector<char> buffer(strsz);
in->sgetn(&buffer[0], strsz);
return std::string(&buffer[0], strsz);
}
}
std::string readstring(const char *d) {
uint16_t strsz = read16(d);
return std::string(d + 2, strsz);
}