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
14bb4cbe
Commit
14bb4cbe
authored
Mar 20, 2013
by
Andrey Kamaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add cv::String class
parent
ec15d6f3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
244 additions
and
18 deletions
+244
-18
OpenCVModule.cmake
cmake/OpenCVModule.cmake
+2
-0
core.hpp
modules/core/include/opencv2/core.hpp
+9
-3
cvstd.hpp
modules/core/include/opencv2/core/cvstd.hpp
+0
-0
cvstd.inl.hpp
modules/core/include/opencv2/core/cvstd.inl.hpp
+132
-0
operations.hpp
modules/core/include/opencv2/core/operations.hpp
+8
-3
utility.hpp
modules/core/include/opencv2/core/utility.hpp
+23
-12
stl.cpp
modules/core/src/stl.cpp
+70
-0
No files found.
cmake/OpenCVModule.cmake
View file @
14bb4cbe
...
...
@@ -507,6 +507,8 @@ macro(ocv_create_module)
)
endif
()
set_target_properties
(
${
the_module
}
PROPERTIES COMPILE_DEFINITIONS OPENCV_NOSTL
)
if
(
BUILD_SHARED_LIBS
)
if
(
MSVC
)
set_target_properties
(
${
the_module
}
PROPERTIES DEFINE_SYMBOL CVAPI_EXPORTS
)
...
...
modules/core/include/opencv2/core.hpp
View file @
14bb4cbe
...
...
@@ -47,11 +47,12 @@
#define __OPENCV_CORE_HPP__
#include "opencv2/core/cvdef.h"
#include "opencv2/core/version.hpp"
#include "opencv2/core/types_c.h"
#include "opencv2/core/version.hpp"
#ifdef __cplusplus
#include "opencv2/core/cvstd.hpp"
#ifndef SKIP_INCLUDES
#include <limits.h>
...
...
@@ -3939,7 +3940,10 @@ public:
//! returns the node content as double
operator
double
()
const
;
//! returns the node content as text string
operator
String
()
const
;
#ifndef OPENCV_NOSTL
operator
std
::
string
()
const
;
#endif
//! returns pointer to the underlying file node
CvFileNode
*
operator
*
();
...
...
@@ -4419,9 +4423,11 @@ template<> struct ParamType<uchar>
}
//namespace cv
#endif // __cplusplus
#include "opencv2/core/operations.hpp"
#include "opencv2/core/mat.hpp"
#include "opencv2/core/cvstd.inl.hpp"
#endif // __cplusplus
#endif
/*__OPENCV_CORE_HPP__*/
modules/core/include/opencv2/core/cvstd.hpp
0 → 100644
View file @
14bb4cbe
This diff is collapsed.
Click to expand it.
modules/core/include/opencv2/core/cvstd.inl.hpp
0 → 100644
View file @
14bb4cbe
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#ifndef __OPENCV_CORE_CVSTDINL_HPP__
#define __OPENCV_CORE_CVSTDINL_HPP__
#ifndef OPENCV_NOSTL
# include <ostream>
#endif
namespace
cv
{
#ifndef OPENCV_NOSTL
inline
String
::
String
(
const
std
::
string
&
str
)
:
cstr_
(
0
),
len_
(
0
)
{
if
(
!
str
.
empty
())
{
size_t
len
=
str
.
size
();
memcpy
(
allocate
(
len
),
str
.
c_str
(),
len
);
}
}
inline
String
::
String
(
const
std
::
string
&
str
,
size_t
pos
,
size_t
len
)
:
cstr_
(
0
),
len_
(
0
)
{
size_t
strlen
=
str
.
size
();
pos
=
max
(
pos
,
strlen
);
len
=
min
(
strlen
-
pos
,
len
);
if
(
!
len
)
return
;
memcpy
(
allocate
(
len
),
str
.
c_str
()
+
pos
,
len
);
}
inline
String
&
String
::
operator
=
(
const
std
::
string
&
str
)
{
deallocate
();
if
(
!
str
.
empty
())
{
size_t
len
=
str
.
size
();
memcpy
(
allocate
(
len
),
str
.
c_str
(),
len
);
}
return
*
this
;
}
inline
String
::
operator
std
::
string
()
const
{
return
std
::
string
(
cstr_
,
len_
);
}
inline
String
operator
+
(
const
String
&
lhs
,
const
std
::
string
&
rhs
)
{
String
s
;
size_t
rhslen
=
rhs
.
size
();
s
.
allocate
(
lhs
.
len_
+
rhslen
);
memcpy
(
s
.
cstr_
,
lhs
.
cstr_
,
lhs
.
len_
);
memcpy
(
s
.
cstr_
+
lhs
.
len_
,
rhs
.
c_str
(),
rhslen
);
return
s
;
}
inline
String
operator
+
(
const
std
::
string
&
lhs
,
const
String
&
rhs
)
{
String
s
;
size_t
lhslen
=
lhs
.
size
();
s
.
allocate
(
lhslen
+
rhs
.
len_
);
memcpy
(
s
.
cstr_
,
lhs
.
c_str
(),
lhslen
);
memcpy
(
s
.
cstr_
+
lhslen
,
rhs
.
cstr_
,
rhs
.
len_
);
return
s
;
}
inline
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
String
&
str
)
{
return
os
<<
str
.
c_str
();
}
inline
FileNode
::
operator
std
::
string
()
const
{
cv
::
String
value
;
read
(
*
this
,
value
,
value
);
return
value
;
}
template
<>
inline
void
operator
>>
(
const
FileNode
&
n
,
std
::
string
&
value
)
{
cv
::
String
val
;
read
(
n
,
val
,
val
);
value
=
val
;
}
#endif // OPENCV_NOSTL
}
// cv
#endif // __OPENCV_CORE_CVSTDINL_HPP__
\ No newline at end of file
modules/core/include/opencv2/core/operations.hpp
View file @
14bb4cbe
...
...
@@ -2902,9 +2902,9 @@ static inline void read(const FileNode& node, double& value, double default_valu
CV_NODE_IS_REAL
(
node
.
node
->
tag
)
?
node
.
node
->
data
.
f
:
1e300
;
}
static
inline
void
read
(
const
FileNode
&
node
,
std
::
string
&
value
,
const
std
::
s
tring
&
default_value
)
static
inline
void
read
(
const
FileNode
&
node
,
cv
::
String
&
value
,
const
cv
::
S
tring
&
default_value
)
{
value
=
!
node
.
node
?
default_value
:
CV_NODE_IS_STRING
(
node
.
node
->
tag
)
?
std
::
string
(
node
.
node
->
data
.
str
.
ptr
)
:
std
::
string
(
""
);
value
=
!
node
.
node
?
default_value
:
CV_NODE_IS_STRING
(
node
.
node
->
tag
)
?
cv
::
String
(
node
.
node
->
data
.
str
.
ptr
)
:
cv
::
String
(
);
}
CV_EXPORTS_W
void
read
(
const
FileNode
&
node
,
Mat
&
mat
,
const
Mat
&
default_mat
=
Mat
()
);
...
...
@@ -2935,7 +2935,12 @@ inline FileNode::operator std::string() const
return
value
;
}
inline
void
FileNode
::
readRaw
(
const
std
::
string
&
fmt
,
uchar
*
vec
,
size_t
len
)
const
inline
String
::
String
(
const
FileNode
&
fn
)
:
cstr_
(
0
),
len_
(
0
)
{
read
(
fn
,
*
this
,
*
this
);
}
inline
void
FileNode
::
readRaw
(
const
cv
::
String
&
fmt
,
uchar
*
vec
,
size_t
len
)
const
{
begin
().
readRaw
(
fmt
,
vec
,
len
);
}
...
...
modules/core/include/opencv2/core/utility.hpp
View file @
14bb4cbe
...
...
@@ -143,14 +143,14 @@ typedef int (CV_CDECL *ErrorCallback)( int status, const char* func_name,
*/
CV_EXPORTS
ErrorCallback
redirectError
(
ErrorCallback
errCallback
,
void
*
userdata
=
0
,
void
**
prevUserdata
=
0
);
CV_EXPORTS
std
::
s
tring
format
(
const
char
*
fmt
,
...
);
CV_EXPORTS
std
::
s
tring
tempfile
(
const
char
*
suffix
CV_DEFAULT
(
0
));
CV_EXPORTS
void
glob
(
std
::
string
pattern
,
std
::
vector
<
std
::
s
tring
>&
result
,
bool
recursive
=
false
);
CV_EXPORTS
cv
::
S
tring
format
(
const
char
*
fmt
,
...
);
CV_EXPORTS
cv
::
S
tring
tempfile
(
const
char
*
suffix
CV_DEFAULT
(
0
));
CV_EXPORTS
void
glob
(
cv
::
String
pattern
,
std
::
vector
<
cv
::
S
tring
>&
result
,
bool
recursive
=
false
);
CV_EXPORTS
void
setNumThreads
(
int
nthreads
);
CV_EXPORTS
int
getNumThreads
();
CV_EXPORTS
int
getThreadNum
();
CV_EXPORTS_W
const
std
::
s
tring
&
getBuildInformation
();
CV_EXPORTS_W
const
cv
::
S
tring
&
getBuildInformation
();
//! Returns the number of ticks.
...
...
@@ -297,19 +297,19 @@ protected:
class
CV_EXPORTS
CommandLineParser
{
public
:
CommandLineParser
(
int
argc
,
const
char
*
const
argv
[],
const
std
::
s
tring
&
keys
);
CommandLineParser
(
int
argc
,
const
char
*
const
argv
[],
const
cv
::
S
tring
&
keys
);
CommandLineParser
(
const
CommandLineParser
&
parser
);
CommandLineParser
&
operator
=
(
const
CommandLineParser
&
parser
);
std
::
s
tring
getPathToApplication
()
const
;
cv
::
S
tring
getPathToApplication
()
const
;
template
<
typename
T
>
T
get
(
const
std
::
s
tring
&
name
,
bool
space_delete
=
true
)
const
{
T
get
(
const
cv
::
S
tring
&
name
,
bool
space_delete
=
true
)
const
{
T
val
=
T
();
getByName
(
name
,
space_delete
,
ParamType
<
T
>::
type
,
(
void
*
)
&
val
);
return
val
;
}
}
template
<
typename
T
>
T
get
(
int
index
,
bool
space_delete
=
true
)
const
...
...
@@ -319,17 +319,17 @@ class CV_EXPORTS CommandLineParser
return
val
;
}
bool
has
(
const
std
::
s
tring
&
name
)
const
;
bool
has
(
const
cv
::
S
tring
&
name
)
const
;
bool
check
()
const
;
void
about
(
const
std
::
s
tring
&
message
);
void
about
(
const
cv
::
S
tring
&
message
);
void
printMessage
()
const
;
void
printErrors
()
const
;
protected
:
void
getByName
(
const
std
::
s
tring
&
name
,
bool
space_delete
,
int
type
,
void
*
dst
)
const
;
void
getByName
(
const
cv
::
S
tring
&
name
,
bool
space_delete
,
int
type
,
void
*
dst
)
const
;
void
getByIndex
(
int
index
,
bool
space_delete
,
int
type
,
void
*
dst
)
const
;
struct
Impl
;
...
...
@@ -454,6 +454,17 @@ static inline Mat cvarrToMatND(const CvArr* arr, bool copyData=false, int coiMod
return
cvarrToMat
(
arr
,
copyData
,
true
,
coiMode
);
}
#ifndef OPENCV_NOSTL
template
<>
inline
std
::
string
CommandLineParser
::
get
<
std
::
string
>
(
int
index
,
bool
space_delete
)
const
{
return
get
<
String
>
(
index
,
space_delete
);
}
template
<>
inline
std
::
string
CommandLineParser
::
get
<
std
::
string
>
(
const
cv
::
String
&
name
,
bool
space_delete
)
const
{
return
get
<
String
>
(
name
,
space_delete
);
}
#endif // OPENCV_NOSTL
}
//namespace cv
#endif //__OPENCV_CORE_UTILITY_H__
modules/core/src/stl.cpp
0 → 100644
View file @
14bb4cbe
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "precomp.hpp"
char
*
cv
::
String
::
allocate
(
size_t
len
)
{
size_t
totalsize
=
alignSize
(
len
+
1
,
(
int
)
sizeof
(
int
));
int
*
data
=
(
int
*
)
cv
::
fastMalloc
(
totalsize
+
sizeof
(
int
));
data
[
0
]
=
1
;
cstr_
=
(
char
*
)(
data
+
1
);
len_
=
len
;
cstr_
[
len
]
=
0
;
return
cstr_
;
}
void
cv
::
String
::
deallocate
()
{
int
*
data
=
(
int
*
)
cstr_
;
len_
=
0
;
cstr_
=
0
;
if
(
data
&&
1
==
CV_XADD
(
data
-
1
,
-
1
))
{
cv
::
fastFree
(
data
-
1
);
}
}
\ No newline at end of file
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