Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
69c9fe35
Commit
69c9fe35
authored
Mar 26, 2013
by
Andrey Kamaev
Committed by
OpenCV Buildbot
Mar 26, 2013
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #702 from taka-no-me:refactor_core_headers
parents
98585a96
aaf69c42
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
338 additions
and
236 deletions
+338
-236
cvdef.h
modules/core/include/opencv2/core/cvdef.h
+13
-5
cvstd.hpp
modules/core/include/opencv2/core/cvstd.hpp
+322
-228
glob.cpp
modules/core/src/glob.cpp
+3
-3
No files found.
modules/core/include/opencv2/core/cvdef.h
View file @
69c9fe35
...
...
@@ -112,15 +112,15 @@
#define CV_HARDWARE_MAX_FEATURE 255
#if defined __SSE2__ || defined _M_X64 || (defined _M_IX86_FP && _M_IX86_FP >= 2)
# include
"emmintrin.h"
# include
<emmintrin.h>
# define CV_SSE 1
# define CV_SSE2 1
# if defined __SSE3__ || (defined _MSC_VER && _MSC_VER >= 1500)
# include
"pmmintrin.h"
# include
<pmmintrin.h>
# define CV_SSE3 1
# endif
# if defined __SSSE3__ || (defined _MSC_VER && _MSC_VER >= 1500)
# include
"tmmintrin.h"
# include
<tmmintrin.h>
# define CV_SSSE3 1
# endif
# if defined __SSE4_1__ || (defined _MSC_VER && _MSC_VER >= 1500)
...
...
@@ -187,7 +187,13 @@
*/
#if !defined _MSC_VER && !defined __BORLANDC__
# include <stdint.h>
# if defined __cplusplus && __cplusplus >= 201103L
# include <cstdint>
# else
# include <stdint.h>
# endif
#else
typedef
unsigned
uint
;
#endif
typedef
signed
char
schar
;
...
...
@@ -318,6 +324,8 @@ typedef signed char schar;
#if defined __BORLANDC__
# include <fastmath.h>
#elif defined __cplusplus
# include <cmath>
#else
# include <math.h>
#endif
...
...
@@ -414,7 +422,7 @@ CV_INLINE int cvIsInf( double value )
# define CV_XADD(addr, delta) __atomic_fetch_add((_Atomic(int)*)(addr), delta, 4)
# endif
# else
# if
def __ATOMIC_ACQ_REL
# if
defined __ATOMIC_ACQ_REL && !defined __clang__
// version for gcc >= 4.7
# define CV_XADD(addr, delta) __atomic_fetch_add(addr, delta, __ATOMIC_ACQ_REL)
# else
...
...
modules/core/include/opencv2/core/cvstd.hpp
View file @
69c9fe35
...
...
@@ -44,11 +44,15 @@
#ifndef __OPENCV_CORE_CVSTD_HPP__
#define __OPENCV_CORE_CVSTD_HPP__
#include <cstddef>
#include <cstring>
#ifndef __cplusplus
# error cvstd.hpp header must be compiled as C++
#endif
#include "opencv2/core/cvdef.h"
#include <cstddef>
#include <cstring>
#ifndef OPENCV_NOSTL
# include <string>
#endif
...
...
@@ -96,299 +100,389 @@ public:
typedef
const
char
*
const_pointer
;
typedef
ptrdiff_t
difference_type
;
typedef
size_t
size_type
;
typedef
char
*
iterator
;
typedef
const
char
*
const_iterator
;
static
const
size_t
npos
=
size_t
(
-
1
);
explicit
String
()
:
cstr_
(
0
),
len_
(
0
)
{}
explicit
String
();
String
(
const
String
&
str
);
String
(
const
String
&
str
,
size_t
pos
,
size_t
len
=
npos
);
String
(
const
char
*
s
);
String
(
const
char
*
s
,
size_t
n
);
String
(
size_t
n
,
char
c
);
String
(
const
char
*
first
,
const
char
*
last
);
template
<
typename
Iterator
>
String
(
Iterator
first
,
Iterator
last
);
explicit
String
(
const
FileNode
&
fn
);
~
String
();
String
(
const
String
&
str
)
:
cstr_
(
str
.
cstr_
),
len_
(
str
.
len_
)
{
if
(
cstr_
)
CV_XADD
(((
int
*
)
cstr_
)
-
1
,
1
);
}
String
&
operator
=
(
const
String
&
str
);
String
&
operator
=
(
const
char
*
s
);
String
&
operator
=
(
char
c
);
String
(
const
String
&
str
,
size_t
pos
,
size_t
len
=
npos
)
:
cstr_
(
0
),
len_
(
0
)
{
pos
=
min
(
pos
,
str
.
len_
);
len
=
min
(
str
.
len_
-
pos
,
len
);
if
(
!
len
)
return
;
if
(
len
==
str
.
len_
)
{
CV_XADD
(((
int
*
)
str
.
cstr_
)
-
1
,
1
);
cstr_
=
str
.
cstr_
;
len_
=
str
.
len_
;
return
;
}
memcpy
(
allocate
(
len
),
str
.
cstr_
+
pos
,
len
);
}
size_t
size
()
const
;
size_t
length
()
const
;
String
(
const
char
*
s
)
:
cstr_
(
0
),
len_
(
0
)
{
if
(
!
s
)
return
;
size_t
len
=
strlen
(
s
);
memcpy
(
allocate
(
len
),
s
,
len
);
}
char
operator
[](
size_t
idx
)
const
;
char
operator
[](
int
idx
)
const
;
String
(
const
char
*
s
,
size_t
n
)
:
cstr_
(
0
),
len_
(
0
)
{
if
(
!
n
)
return
;
memcpy
(
allocate
(
n
),
s
,
n
);
}
const
char
*
begin
()
const
;
const
char
*
end
()
const
;
String
(
size_t
n
,
char
c
)
:
cstr_
(
0
),
len_
(
0
)
{
memset
(
allocate
(
n
),
c
,
n
);
}
const
char
*
c_str
()
const
;
String
(
const
char
*
first
,
const
char
*
last
)
:
cstr_
(
0
),
len_
(
0
)
{
size_t
len
=
(
size_t
)(
last
-
first
);
memcpy
(
allocate
(
len
),
first
,
len
);
}
bool
empty
()
const
;
void
clear
();
template
<
typename
Iterator
>
String
(
Iterator
first
,
Iterator
last
)
:
cstr_
(
0
),
len_
(
0
)
{
size_t
len
=
(
size_t
)(
last
-
first
);
char
*
str
=
allocate
(
len
);
while
(
first
!=
last
)
{
*
str
++
=
*
first
;
++
first
;
}
}
int
compare
(
const
char
*
s
)
const
;
int
compare
(
const
String
&
str
)
const
;
void
swap
(
String
&
str
);
String
substr
(
size_t
pos
=
0
,
size_t
len
=
npos
)
const
;
size_t
find
(
const
char
*
s
,
size_t
pos
,
size_t
n
)
const
;
size_t
find
(
char
c
,
size_t
pos
=
0
)
const
;
size_t
find
(
const
String
&
str
,
size_t
pos
=
0
)
const
;
size_t
find
(
const
char
*
s
,
size_t
pos
=
0
)
const
;
size_t
rfind
(
const
char
*
s
,
size_t
pos
,
size_t
n
)
const
;
size_t
rfind
(
char
c
,
size_t
pos
=
npos
)
const
;
size_t
rfind
(
const
String
&
str
,
size_t
pos
=
npos
)
const
;
size_t
rfind
(
const
char
*
s
,
size_t
pos
=
npos
)
const
;
size_t
find_first_of
(
const
char
*
s
,
size_t
pos
,
size_t
n
)
const
;
size_t
find_first_of
(
char
c
,
size_t
pos
=
0
)
const
;
size_t
find_first_of
(
const
String
&
str
,
size_t
pos
=
0
)
const
;
size_t
find_first_of
(
const
char
*
s
,
size_t
pos
=
0
)
const
;
size_t
find_last_of
(
const
char
*
s
,
size_t
pos
,
size_t
n
)
const
;
size_t
find_last_of
(
char
c
,
size_t
pos
=
npos
)
const
;
size_t
find_last_of
(
const
String
&
str
,
size_t
pos
=
npos
)
const
;
size_t
find_last_of
(
const
char
*
s
,
size_t
pos
=
npos
)
const
;
friend
String
operator
+
(
const
String
&
lhs
,
const
String
&
rhs
);
friend
String
operator
+
(
const
String
&
lhs
,
const
char
*
rhs
);
friend
String
operator
+
(
const
char
*
lhs
,
const
String
&
rhs
);
friend
String
operator
+
(
const
String
&
lhs
,
char
rhs
);
friend
String
operator
+
(
char
lhs
,
const
String
&
rhs
);
#ifndef OPENCV_NOSTL
String
(
const
std
::
string
&
str
);
String
(
const
std
::
string
&
str
,
size_t
pos
,
size_t
len
=
npos
);
String
&
operator
=
(
const
std
::
string
&
str
);
operator
std
::
string
()
const
;
friend
String
operator
+
(
const
String
&
lhs
,
const
std
::
string
&
rhs
);
friend
String
operator
+
(
const
std
::
string
&
lhs
,
const
String
&
rhs
);
#endif
private
:
char
*
cstr_
;
size_t
len_
;
char
*
allocate
(
size_t
len
);
// len without trailing 0
void
deallocate
();
};
~
String
()
{
deallocate
();
}
// **************************** cv::String implementation ****************************
String
&
operator
=
(
const
String
&
str
)
inline
String
::
String
()
:
cstr_
(
0
),
len_
(
0
)
{
}
inline
String
::
String
(
const
String
&
str
)
:
cstr_
(
str
.
cstr_
),
len_
(
str
.
len_
)
{
if
(
cstr_
)
CV_XADD
(((
int
*
)
cstr_
)
-
1
,
1
);
}
inline
String
::
String
(
const
String
&
str
,
size_t
pos
,
size_t
len
)
:
cstr_
(
0
),
len_
(
0
)
{
pos
=
min
(
pos
,
str
.
len_
);
len
=
min
(
str
.
len_
-
pos
,
len
);
if
(
!
len
)
return
;
if
(
len
==
str
.
len_
)
{
deallocate
();
if
(
str
.
cstr_
)
CV_XADD
(((
int
*
)
str
.
cstr_
)
-
1
,
1
);
CV_XADD
(((
int
*
)
str
.
cstr_
)
-
1
,
1
);
cstr_
=
str
.
cstr_
;
len_
=
str
.
len_
;
return
*
this
;
return
;
}
memcpy
(
allocate
(
len
),
str
.
cstr_
+
pos
,
len
);
}
String
&
operator
=
(
const
char
*
s
)
{
deallocate
();
if
(
!
s
)
return
*
this
;
size_t
len
=
strlen
(
s
);
memcpy
(
allocate
(
len
),
s
,
len
);
return
*
this
;
}
inline
String
::
String
(
const
char
*
s
)
:
cstr_
(
0
),
len_
(
0
)
{
if
(
!
s
)
return
;
size_t
len
=
strlen
(
s
);
memcpy
(
allocate
(
len
),
s
,
len
);
}
inline
String
::
String
(
const
char
*
s
,
size_t
n
)
:
cstr_
(
0
),
len_
(
0
)
{
if
(
!
n
)
return
;
memcpy
(
allocate
(
n
),
s
,
n
);
}
inline
String
::
String
(
size_t
n
,
char
c
)
:
cstr_
(
0
),
len_
(
0
)
{
memset
(
allocate
(
n
),
c
,
n
);
}
inline
String
::
String
(
const
char
*
first
,
const
char
*
last
)
:
cstr_
(
0
),
len_
(
0
)
{
size_t
len
=
(
size_t
)(
last
-
first
);
memcpy
(
allocate
(
len
),
first
,
len
);
}
String
&
operator
=
(
char
c
)
template
<
typename
Iterator
>
inline
String
::
String
(
Iterator
first
,
Iterator
last
)
:
cstr_
(
0
),
len_
(
0
)
{
size_t
len
=
(
size_t
)(
last
-
first
);
char
*
str
=
allocate
(
len
);
while
(
first
!=
last
)
{
deallocate
();
allocate
(
1
)[
0
]
=
c
;
return
*
this
;
*
str
++
=
*
first
;
++
first
;
}
}
size_t
size
()
const
{
return
len_
;
}
size_t
length
()
const
{
return
len_
;
}
inline
String
::~
String
()
{
deallocate
();
}
char
operator
[](
size_t
idx
)
const
{
return
cstr_
[
idx
];
}
char
operator
[](
int
idx
)
const
{
return
cstr_
[
idx
];
}
inline
String
&
String
::
operator
=
(
const
String
&
str
)
{
deallocate
();
if
(
str
.
cstr_
)
CV_XADD
(((
int
*
)
str
.
cstr_
)
-
1
,
1
);
cstr_
=
str
.
cstr_
;
len_
=
str
.
len_
;
return
*
this
;
}
const
char
*
begin
()
const
{
return
cstr_
;
}
const
char
*
end
()
const
{
return
len_
?
cstr_
+
1
:
0
;
}
inline
String
&
String
::
operator
=
(
const
char
*
s
)
{
deallocate
();
if
(
!
s
)
return
*
this
;
size_t
len
=
strlen
(
s
);
memcpy
(
allocate
(
len
),
s
,
len
);
return
*
this
;
}
bool
empty
()
const
{
return
len_
==
0
;
}
inline
String
&
String
::
operator
=
(
char
c
)
{
deallocate
();
allocate
(
1
)[
0
]
=
c
;
return
*
this
;
}
const
char
*
c_str
()
const
{
return
cstr_
?
cstr_
:
""
;
}
inline
size_t
String
::
size
()
const
{
return
len_
;
}
void
swap
(
String
&
str
)
{
cv
::
swap
(
cstr_
,
str
.
cstr_
);
cv
::
swap
(
len_
,
str
.
len_
);
}
inline
size_t
String
::
length
()
const
{
return
len_
;
}
void
clear
()
{
deallocate
();
}
inline
char
String
::
operator
[](
size_t
idx
)
const
{
return
cstr_
[
idx
];
}
int
compare
(
const
char
*
s
)
const
{
if
(
cstr_
==
s
)
return
0
;
inline
char
String
::
operator
[](
int
idx
)
const
{
return
cstr_
[
idx
];
}
return
strcmp
(
c_str
(),
s
);
}
inline
const
char
*
String
::
begin
()
const
{
return
cstr_
;
}
int
compare
(
const
String
&
str
)
const
{
if
(
cstr_
==
str
.
cstr_
)
return
0
;
inline
const
char
*
String
::
end
()
const
{
return
len_
?
cstr_
+
1
:
0
;
}
return
strcmp
(
c_str
(),
str
.
c_str
());
}
inline
bool
String
::
empty
()
const
{
return
len_
==
0
;
}
String
substr
(
size_t
pos
=
0
,
size_t
len
=
npos
)
const
{
return
String
(
*
this
,
pos
,
len
)
;
}
inline
const
char
*
String
::
c_str
(
)
const
{
return
cstr_
?
cstr_
:
""
;
}
size_t
find
(
const
char
*
s
,
size_t
pos
,
size_t
n
)
const
{
if
(
n
==
0
||
pos
+
n
>
len_
)
return
npos
;
const
char
*
lmax
=
cstr_
+
len_
-
n
;
for
(
const
char
*
i
=
cstr_
+
pos
;
i
<=
lmax
;
++
i
)
{
size_t
j
=
0
;
while
(
j
<
n
&&
s
[
j
]
==
i
[
j
])
++
j
;
if
(
j
==
n
)
return
(
size_t
)(
i
-
cstr_
);
}
return
npos
;
}
inline
void
String
::
swap
(
String
&
str
)
{
cv
::
swap
(
cstr_
,
str
.
cstr_
);
cv
::
swap
(
len_
,
str
.
len_
);
}
size_t
find
(
char
c
,
size_t
pos
=
0
)
const
{
return
find
(
&
c
,
pos
,
1
);
}
inline
void
String
::
clear
()
{
deallocate
(
);
}
size_t
find
(
const
String
&
str
,
size_t
pos
=
0
)
const
{
return
find
(
str
.
c_str
(),
pos
,
str
.
len_
);
}
inline
int
String
::
compare
(
const
char
*
s
)
const
{
if
(
cstr_
==
s
)
return
0
;
return
strcmp
(
c_str
(),
s
);
}
size_t
find
(
const
char
*
s
,
size_t
pos
=
0
)
const
{
if
(
pos
>=
len_
||
!
s
[
0
])
return
npos
;
const
char
*
lmax
=
cstr_
+
len_
;
for
(
const
char
*
i
=
cstr_
+
pos
;
i
<
lmax
;
++
i
)
{
size_t
j
=
0
;
while
(
s
[
j
]
&&
s
[
j
]
==
i
[
j
])
{
if
(
i
+
j
>=
lmax
)
return
npos
;
++
j
;
}
if
(
!
s
[
j
])
return
(
size_t
)(
i
-
cstr_
);
}
return
npos
;
}
inline
int
String
::
compare
(
const
String
&
str
)
const
{
if
(
cstr_
==
str
.
cstr_
)
return
0
;
return
strcmp
(
c_str
(),
str
.
c_str
());
}
size_t
rfind
(
const
char
*
s
,
size_t
pos
,
size_t
n
)
const
{
if
(
n
>
len_
)
return
npos
;
if
(
pos
>
len_
-
n
)
pos
=
len_
-
n
;
for
(
const
char
*
i
=
cstr_
+
pos
;
i
>=
cstr_
;
--
i
)
{
size_t
j
=
0
;
while
(
j
<
n
&&
s
[
j
]
==
i
[
j
])
++
j
;
if
(
j
==
n
)
return
(
size_t
)(
i
-
cstr_
);
}
return
npos
;
}
inline
String
String
::
substr
(
size_t
pos
,
size_t
len
)
const
{
return
String
(
*
this
,
pos
,
len
);
}
size_t
rfind
(
char
c
,
size_t
pos
=
npos
)
const
inline
size_t
String
::
find
(
const
char
*
s
,
size_t
pos
,
size_t
n
)
const
{
if
(
n
==
0
||
pos
+
n
>
len_
)
return
npos
;
const
char
*
lmax
=
cstr_
+
len_
-
n
;
for
(
const
char
*
i
=
cstr_
+
pos
;
i
<=
lmax
;
++
i
)
{
return
rfind
(
&
c
,
pos
,
1
);
size_t
j
=
0
;
while
(
j
<
n
&&
s
[
j
]
==
i
[
j
])
++
j
;
if
(
j
==
n
)
return
(
size_t
)(
i
-
cstr_
);
}
return
npos
;
}
size_t
rfind
(
const
String
&
str
,
size_t
pos
=
n
pos
)
const
{
return
rfind
(
str
.
c_str
(),
pos
,
str
.
len_
);
}
inline
size_t
String
::
find
(
char
c
,
size_t
pos
)
const
{
return
find
(
&
c
,
pos
,
1
);
}
size_t
rfind
(
const
char
*
s
,
size_t
pos
=
n
pos
)
const
{
return
rfind
(
s
,
pos
,
strlen
(
s
)
);
}
inline
size_t
String
::
find
(
const
String
&
str
,
size_t
pos
)
const
{
return
find
(
str
.
c_str
(),
pos
,
str
.
len_
);
}
size_t
find_first_of
(
const
char
*
s
,
size_t
pos
,
size_t
n
)
const
inline
size_t
String
::
find
(
const
char
*
s
,
size_t
pos
)
const
{
if
(
pos
>=
len_
||
!
s
[
0
])
return
npos
;
const
char
*
lmax
=
cstr_
+
len_
;
for
(
const
char
*
i
=
cstr_
+
pos
;
i
<
lmax
;
++
i
)
{
if
(
n
==
0
||
pos
+
n
>
len_
)
return
npos
;
const
char
*
lmax
=
cstr_
+
len_
;
for
(
const
char
*
i
=
cstr_
+
pos
;
i
<
lmax
;
++
i
)
{
for
(
size_t
j
=
0
;
j
<
n
;
++
j
)
if
(
s
[
j
]
==
*
i
)
return
(
size_t
)(
i
-
cstr_
);
size_t
j
=
0
;
while
(
s
[
j
]
&&
s
[
j
]
==
i
[
j
])
{
if
(
i
+
j
>=
lmax
)
return
npos
;
++
j
;
}
return
npos
;
if
(
!
s
[
j
])
return
(
size_t
)(
i
-
cstr_
)
;
}
return
npos
;
}
size_t
find_first_of
(
char
c
,
size_t
pos
=
0
)
const
inline
size_t
String
::
rfind
(
const
char
*
s
,
size_t
pos
,
size_t
n
)
const
{
if
(
n
>
len_
)
return
npos
;
if
(
pos
>
len_
-
n
)
pos
=
len_
-
n
;
for
(
const
char
*
i
=
cstr_
+
pos
;
i
>=
cstr_
;
--
i
)
{
return
find_first_of
(
&
c
,
pos
,
1
);
size_t
j
=
0
;
while
(
j
<
n
&&
s
[
j
]
==
i
[
j
])
++
j
;
if
(
j
==
n
)
return
(
size_t
)(
i
-
cstr_
);
}
return
npos
;
}
size_t
find_first_of
(
const
String
&
str
,
size_t
pos
=
0
)
const
{
return
find_first_of
(
str
.
c_str
(),
pos
,
str
.
len_
);
}
inline
size_t
String
::
rfind
(
char
c
,
size_t
pos
)
const
{
return
rfind
(
&
c
,
pos
,
1
);
}
size_t
find_first_of
(
const
char
*
s
,
size_t
pos
=
0
)
const
{
if
(
pos
>=
len_
||
!
s
[
0
])
return
npos
;
const
char
*
lmax
=
cstr_
+
len_
;
for
(
const
char
*
i
=
cstr_
+
pos
;
i
<
lmax
;
++
i
)
{
for
(
size_t
j
=
0
;
s
[
j
];
++
j
)
if
(
s
[
j
]
==
*
i
)
return
(
size_t
)(
i
-
cstr_
);
}
return
npos
;
}
inline
size_t
String
::
rfind
(
const
String
&
str
,
size_t
pos
)
const
{
return
rfind
(
str
.
c_str
(),
pos
,
str
.
len_
);
}
size_t
find_last_of
(
const
char
*
s
,
size_t
pos
,
size_t
n
)
const
{
if
(
pos
>=
len_
)
pos
=
len_
-
1
;
for
(
const
char
*
i
=
cstr_
+
pos
;
i
>=
cstr_
;
--
i
)
{
for
(
size_t
j
=
0
;
j
<
n
;
++
j
)
if
(
s
[
j
]
==
*
i
)
return
(
size_t
)(
i
-
cstr_
);
}
return
npos
;
}
inline
size_t
String
::
rfind
(
const
char
*
s
,
size_t
pos
)
const
{
return
rfind
(
s
,
pos
,
strlen
(
s
));
}
size_t
find_last_of
(
char
c
,
size_t
pos
=
npos
)
const
inline
size_t
String
::
find_first_of
(
const
char
*
s
,
size_t
pos
,
size_t
n
)
const
{
if
(
n
==
0
||
pos
+
n
>
len_
)
return
npos
;
const
char
*
lmax
=
cstr_
+
len_
;
for
(
const
char
*
i
=
cstr_
+
pos
;
i
<
lmax
;
++
i
)
{
return
find_last_of
(
&
c
,
pos
,
1
);
for
(
size_t
j
=
0
;
j
<
n
;
++
j
)
if
(
s
[
j
]
==
*
i
)
return
(
size_t
)(
i
-
cstr_
);
}
return
npos
;
}
inline
size_t
String
::
find_first_of
(
char
c
,
size_t
pos
)
const
{
return
find_first_of
(
&
c
,
pos
,
1
);
}
size_t
find_last_of
(
const
String
&
str
,
size_t
pos
=
npos
)
const
inline
size_t
String
::
find_first_of
(
const
String
&
str
,
size_t
pos
)
const
{
return
find_first_of
(
str
.
c_str
(),
pos
,
str
.
len_
);
}
inline
size_t
String
::
find_first_of
(
const
char
*
s
,
size_t
pos
)
const
{
if
(
pos
>=
len_
||
!
s
[
0
])
return
npos
;
const
char
*
lmax
=
cstr_
+
len_
;
for
(
const
char
*
i
=
cstr_
+
pos
;
i
<
lmax
;
++
i
)
{
return
find_last_of
(
str
.
c_str
(),
pos
,
str
.
len_
);
for
(
size_t
j
=
0
;
s
[
j
];
++
j
)
if
(
s
[
j
]
==
*
i
)
return
(
size_t
)(
i
-
cstr_
);
}
return
npos
;
}
size_t
find_last_of
(
const
char
*
s
,
size_t
pos
=
npos
)
const
inline
size_t
String
::
find_last_of
(
const
char
*
s
,
size_t
pos
,
size_t
n
)
const
{
if
(
pos
>=
len_
)
pos
=
len_
-
1
;
for
(
const
char
*
i
=
cstr_
+
pos
;
i
>=
cstr_
;
--
i
)
{
if
(
pos
>=
len_
)
pos
=
len_
-
1
;
for
(
const
char
*
i
=
cstr_
+
pos
;
i
>=
cstr_
;
--
i
)
{
for
(
size_t
j
=
0
;
s
[
j
];
++
j
)
if
(
s
[
j
]
==
*
i
)
return
(
size_t
)(
i
-
cstr_
);
}
return
npos
;
for
(
size_t
j
=
0
;
j
<
n
;
++
j
)
if
(
s
[
j
]
==
*
i
)
return
(
size_t
)(
i
-
cstr_
);
}
return
npos
;
}
friend
String
operator
+
(
const
String
&
lhs
,
const
String
&
rhs
);
friend
String
operator
+
(
const
String
&
lhs
,
const
char
*
rhs
);
friend
String
operator
+
(
const
char
*
lhs
,
const
String
&
rhs
);
friend
String
operator
+
(
const
String
&
lhs
,
char
rhs
);
friend
String
operator
+
(
char
lhs
,
const
String
&
rhs
);
#ifndef OPENCV_NOSTL
String
(
const
std
::
string
&
str
);
String
(
const
std
::
string
&
str
,
size_t
pos
,
size_t
len
=
npos
);
String
&
operator
=
(
const
std
::
string
&
str
);
operator
std
::
string
()
const
;
friend
String
operator
+
(
const
String
&
lhs
,
const
std
::
string
&
rhs
);
friend
String
operator
+
(
const
std
::
string
&
lhs
,
const
String
&
rhs
);
#endif
inline
size_t
String
::
find_last_of
(
char
c
,
size_t
pos
)
const
{
return
find_last_of
(
&
c
,
pos
,
1
);
}
explicit
String
(
const
FileNode
&
fn
);
inline
size_t
String
::
find_last_of
(
const
String
&
str
,
size_t
pos
)
const
{
return
find_last_of
(
str
.
c_str
(),
pos
,
str
.
len_
);
}
private
:
char
*
cstr_
;
size_t
len_
;
inline
size_t
String
::
find_last_of
(
const
char
*
s
,
size_t
pos
)
const
{
if
(
pos
>=
len_
)
pos
=
len_
-
1
;
for
(
const
char
*
i
=
cstr_
+
pos
;
i
>=
cstr_
;
--
i
)
{
for
(
size_t
j
=
0
;
s
[
j
];
++
j
)
if
(
s
[
j
]
==
*
i
)
return
(
size_t
)(
i
-
cstr_
);
}
return
npos
;
}
char
*
allocate
(
size_t
len
);
// len_ without trailing 0
void
deallocate
();
};
// ************************* cv::String non-member functions *************************
inline
String
operator
+
(
const
String
&
lhs
,
const
String
&
rhs
)
{
...
...
modules/core/src/glob.cpp
View file @
69c9fe35
...
...
@@ -111,11 +111,11 @@ static bool isDir(const cv::String& path, DIR* dir)
return
(
attributes
!=
INVALID_FILE_ATTRIBUTES
)
&&
((
attributes
&
FILE_ATTRIBUTE_DIRECTORY
)
!=
0
);
#else
(
void
)
dir
;
struct
stat
stat_buf
;
stat
(
path
.
c_str
(),
&
stat_buf
);
if
(
0
!=
stat
(
path
.
c_str
(),
&
stat_buf
))
return
false
;
int
is_dir
=
S_ISDIR
(
stat_buf
.
st_mode
);
(
void
)
dir
;
return
is_dir
!=
0
;
#endif
}
...
...
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