Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
e6d7f93d
Commit
e6d7f93d
authored
Nov 18, 2012
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added seekg() and made vectorstream more robust.
parent
45d21205
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
4 deletions
+29
-4
vectorstream.h
dlib/vectorstream/vectorstream.h
+18
-4
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