Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
e6d7f93d
"vscode:/vscode.git/clone" did not exist on "63aed582043a7ce5b2633e9505adb9ff6f24f99c"
Commit
e6d7f93d
authored
Nov 18, 2012
by
Davis King
Browse files
Added seekg() and made vectorstream more robust.
parent
45d21205
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
4 deletions
+29
-4
dlib/vectorstream/vectorstream.h
dlib/vectorstream/vectorstream.h
+18
-4
dlib/vectorstream/vectorstream_abstract.h
dlib/vectorstream/vectorstream_abstract.h
+11
-0
No files found.
dlib/vectorstream/vectorstream.h
View file @
e6d7f93d
...
...
@@ -29,6 +29,12 @@ namespace dlib
buffer
(
buffer_
)
{}
void
seekg
(
size_type
pos
)
{
read_pos
=
pos
;
}
// ------------------------ OUTPUT FUNCTIONS ------------------------
int_type
overflow
(
int_type
c
)
...
...
@@ -85,15 +91,15 @@ namespace dlib
std
::
streamsize
n
)
{
const
size_type
num
=
std
::
min
<
size_type
>
(
n
,
buffer
.
size
()
-
read_pos
);
if
(
num
>
0
)
if
(
read_pos
<
buffer
.
size
())
{
const
size_type
num
=
std
::
min
<
size_type
>
(
n
,
buffer
.
size
()
-
read_pos
);
std
::
memcpy
(
s
,
&
buffer
[
read_pos
],
num
);
read_pos
+=
num
;
}
return
num
;
}
return
0
;
}
};
...
...
@@ -106,6 +112,14 @@ namespace dlib
buf
(
buffer
)
{}
std
::
istream
&
seekg
(
std
::
streampos
pos
)
{
buf
.
seekg
(
pos
);
return
*
this
;
}
private:
vector_streambuf
buf
;
};
...
...
dlib/vectorstream/vectorstream_abstract.h
View file @
e6d7f93d
...
...
@@ -43,6 +43,17 @@ namespace dlib
immediately show up in the buffer.
!*/
std
::
istream
&
seekg
(
std
::
streampos
pos
);
/*!
ensures
- The next read from this object will read from the position buffer[pos],
where buffer is the std::vector given to this object's constructor. Note
that if pos >= buffer.size() then the next read will simply return EOF.
- returns *this
!*/
};
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment