Commit ae8dcdf4 authored by Vladislav Sovrasov's avatar Vladislav Sovrasov Committed by Alexander Alekhin

core: get rid of built-in String type

parent ee1e1ce3
This diff is collapsed.
...@@ -73,69 +73,6 @@ public: ...@@ -73,69 +73,6 @@ public:
typedef Vec<channel_type, channels> vec_type; typedef Vec<channel_type, channels> vec_type;
}; };
inline
String::String(const std::string& str)
: cstr_(0), len_(0)
{
size_t len = str.size();
if (len) 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 = min(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();
size_t len = str.size();
if (len) memcpy(allocate(len), str.c_str(), len);
return *this;
}
inline
String& String::operator += (const std::string& str)
{
*this = *this + str;
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);
if (lhs.len_) memcpy(s.cstr_, lhs.cstr_, lhs.len_);
if (rhslen) 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_);
if (lhslen) memcpy(s.cstr_, lhs.c_str(), lhslen);
if (rhs.len_) memcpy(s.cstr_ + lhslen, rhs.cstr_, rhs.len_);
return s;
}
inline inline
FileNode::operator std::string() const FileNode::operator std::string() const
{ {
......
...@@ -576,7 +576,6 @@ public: ...@@ -576,7 +576,6 @@ public:
//! returns the node content as double //! returns the node content as double
operator double() const; operator double() const;
//! returns the node content as text string //! returns the node content as text string
operator String() const;
operator std::string() const; operator std::string() const;
//! returns pointer to the underlying file node //! returns pointer to the underlying file node
...@@ -1334,7 +1333,6 @@ inline const CvFileNode* FileNode::operator* () const { return node; } ...@@ -1334,7 +1333,6 @@ inline const CvFileNode* FileNode::operator* () const { return node; }
inline FileNode::operator int() const { int value; read(*this, value, 0); return value; } inline FileNode::operator int() const { int value; read(*this, value, 0); return value; }
inline FileNode::operator float() const { float value; read(*this, value, 0.f); return value; } inline FileNode::operator float() const { float value; read(*this, value, 0.f); return value; }
inline FileNode::operator double() const { double value; read(*this, value, 0.); return value; } inline FileNode::operator double() const { double value; read(*this, value, 0.); return value; }
inline FileNode::operator String() const { String value; read(*this, value, value); return value; }
inline double FileNode::real() const { return double(*this); } inline double FileNode::real() const { return double(*this); }
inline String FileNode::string() const { return String(*this); } inline String FileNode::string() const { return String(*this); }
inline Mat FileNode::mat() const { Mat value; read(*this, value, value); return value; } inline Mat FileNode::mat() const { Mat value; read(*this, value, value); return value; }
...@@ -1343,7 +1341,6 @@ inline FileNodeIterator FileNode::end() const { return FileNodeIterator(fs, no ...@@ -1343,7 +1341,6 @@ inline FileNodeIterator FileNode::end() const { return FileNodeIterator(fs, no
inline void FileNode::readRaw( const String& fmt, uchar* vec, size_t len ) const { begin().readRaw( fmt, vec, len ); } inline void FileNode::readRaw( const String& fmt, uchar* vec, size_t len ) const { begin().readRaw( fmt, vec, len ); }
inline FileNode FileNodeIterator::operator *() const { return FileNode(fs, (const CvFileNode*)(const void*)reader.ptr); } inline FileNode FileNodeIterator::operator *() const { return FileNode(fs, (const CvFileNode*)(const void*)reader.ptr); }
inline FileNode FileNodeIterator::operator ->() const { return FileNode(fs, (const CvFileNode*)(const void*)reader.ptr); } inline FileNode FileNodeIterator::operator ->() const { return FileNode(fs, (const CvFileNode*)(const void*)reader.ptr); }
inline String::String(const FileNode& fn): cstr_(0), len_(0) { read(fn, *this, *this); }
//! @endcond //! @endcond
......
...@@ -1053,15 +1053,6 @@ template<typename _Tp, size_t fixed_size> inline size_t ...@@ -1053,15 +1053,6 @@ template<typename _Tp, size_t fixed_size> inline size_t
AutoBuffer<_Tp, fixed_size>::size() const AutoBuffer<_Tp, fixed_size>::size() const
{ return sz; } { return sz; }
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 String& name, bool space_delete) const
{
return get<String>(name, space_delete);
}
//! @endcond //! @endcond
......
...@@ -43,27 +43,3 @@ ...@@ -43,27 +43,3 @@
#include "precomp.hpp" #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);
}
}
...@@ -1953,7 +1953,9 @@ public: ...@@ -1953,7 +1953,9 @@ public:
ippFeatures = cpuFeatures; ippFeatures = cpuFeatures;
const char* pIppEnv = getenv("OPENCV_IPP"); const char* pIppEnv = getenv("OPENCV_IPP");
cv::String env = pIppEnv; cv::String env;
if(pIppEnv != NULL)
env = pIppEnv;
if(env.size()) if(env.size())
{ {
#if IPP_VERSION_X100 >= 201703 #if IPP_VERSION_X100 >= 201703
......
...@@ -2388,7 +2388,7 @@ NCVStatus ncvHaarGetClassifierSize(const cv::String &filename, Ncv32u &numStages ...@@ -2388,7 +2388,7 @@ NCVStatus ncvHaarGetClassifierSize(const cv::String &filename, Ncv32u &numStages
NCVStatus ncvStat; NCVStatus ncvStat;
cv::String fext = filename.substr(filename.find_last_of(".") + 1); cv::String fext = filename.substr(filename.find_last_of(".") + 1);
fext = fext.toLowerCase(); std::transform(fext.begin(), fext.end(), fext.begin(), ::tolower);
if (fext == "nvbin") if (fext == "nvbin")
{ {
...@@ -2446,7 +2446,7 @@ NCVStatus ncvHaarLoadFromFile_host(const cv::String &filename, ...@@ -2446,7 +2446,7 @@ NCVStatus ncvHaarLoadFromFile_host(const cv::String &filename,
NCVStatus ncvStat; NCVStatus ncvStat;
cv::String fext = filename.substr(filename.find_last_of(".") + 1); cv::String fext = filename.substr(filename.find_last_of(".") + 1);
fext = fext.toLowerCase(); std::transform(fext.begin(), fext.end(), fext.begin(), ::tolower);
std::vector<HaarStage64> haarStages; std::vector<HaarStage64> haarStages;
std::vector<HaarClassifierNode128> haarNodes; std::vector<HaarClassifierNode128> haarNodes;
......
...@@ -809,7 +809,7 @@ namespace ...@@ -809,7 +809,7 @@ namespace
Ptr<cuda::CascadeClassifier> cv::cuda::CascadeClassifier::create(const String& filename) Ptr<cuda::CascadeClassifier> cv::cuda::CascadeClassifier::create(const String& filename)
{ {
String fext = filename.substr(filename.find_last_of(".") + 1); String fext = filename.substr(filename.find_last_of(".") + 1);
fext = fext.toLowerCase(); std::transform(fext.begin(), fext.end(), fext.begin(), ::tolower);
if (fext == "nvbin") if (fext == "nvbin")
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment