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
7e8109b7
Commit
7e8109b7
authored
Mar 11, 2016
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made cerr print in matlab as a red warning message.
parent
82a4f00a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
1 deletion
+53
-1
mex_wrapper.cpp
dlib/matlab/mex_wrapper.cpp
+53
-1
No files found.
dlib/matlab/mex_wrapper.cpp
View file @
7e8109b7
...
@@ -2935,6 +2935,56 @@ namespace mex_binding
...
@@ -2935,6 +2935,56 @@ namespace mex_binding
};
};
class
mex_warn_streambuf
:
public
std
::
streambuf
{
public
:
mex_warn_streambuf
(
)
{
buf
.
resize
(
1000
);
setp
(
&
buf
[
0
],
&
buf
[
0
]
+
buf
.
size
()
-
2
);
// make cout send data to mex_warn_streambuf
std
::
cout
.
rdbuf
(
this
);
}
protected
:
int
sync
(
)
{
int
num
=
static_cast
<
int
>
(
pptr
()
-
pbase
());
if
(
num
!=
0
)
{
buf
[
num
]
=
0
;
// null terminate the string
mexWarnMsgTxt
(
&
buf
[
0
]);
mexEvalString
(
"drawnow"
);
// flush print to screen
pbump
(
-
num
);
}
return
0
;
}
int_type
overflow
(
int_type
c
)
{
if
(
c
!=
EOF
)
{
*
pptr
()
=
c
;
pbump
(
1
);
}
sync
();
return
c
;
}
private
:
std
::
vector
<
char
>
buf
;
};
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
...
@@ -4438,10 +4488,12 @@ namespace dlib
...
@@ -4438,10 +4488,12 @@ namespace dlib
void
mexFunction
(
int
nlhs
,
mxArray
*
plhs
[],
void
mexFunction
(
int
nlhs
,
mxArray
*
plhs
[],
int
nrhs
,
const
mxArray
*
prhs
[])
int
nrhs
,
const
mxArray
*
prhs
[])
{
{
// Only remap cout if we aren't using octave since octave already does this.
// Only remap cout
and cerr
if we aren't using octave since octave already does this.
#if !defined(OCTAVE_IMPORT) && !defined(OCTAVE_API)
#if !defined(OCTAVE_IMPORT) && !defined(OCTAVE_API)
// make it so cout prints to mexPrintf()
// make it so cout prints to mexPrintf()
static
mex_binding
::
mex_streambuf
sb
;
static
mex_binding
::
mex_streambuf
sb
;
// make it so cerr prints to mexWarnMsgTxt()
static
mex_binding
::
mex_warn_streambuf
wsb
;
#endif
#endif
mex_binding
::
call_mex_function
(
mex_function
,
nlhs
,
plhs
,
nrhs
,
prhs
);
mex_binding
::
call_mex_function
(
mex_function
,
nlhs
,
plhs
,
nrhs
,
prhs
);
...
...
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