Skip to content

Commit 6dd9e18

Browse files
PkLab.netsovrasov
authored andcommitted
add std::string overload for cv::read()
1 parent 5b833db commit 6dd9e18

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

modules/core/include/opencv2/core/cvstd.inl.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,7 @@ FileNode::operator std::string() const
156156
template<> inline
157157
void operator >> (const FileNode& n, std::string& value)
158158
{
159-
String val;
160-
read(n, val, val);
161-
value = val;
159+
read(n, value, std::string());
162160
}
163161

164162
template<> inline

modules/core/include/opencv2/core/persistence.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,7 @@ CV_EXPORTS void read(const FileNode& node, int& value, int default_value);
714714
CV_EXPORTS void read(const FileNode& node, float& value, float default_value);
715715
CV_EXPORTS void read(const FileNode& node, double& value, double default_value);
716716
CV_EXPORTS void read(const FileNode& node, String& value, const String& default_value);
717+
CV_EXPORTS void read(const FileNode& node, std::string& value, const std::string& default_value);
717718
CV_EXPORTS void read(const FileNode& node, Mat& mat, const Mat& default_mat = Mat() );
718719
CV_EXPORTS void read(const FileNode& node, SparseMat& mat, const SparseMat& default_mat = SparseMat() );
719720
CV_EXPORTS void read(const FileNode& node, std::vector<KeyPoint>& keypoints);

modules/core/src/persistence.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7396,6 +7396,11 @@ void read(const FileNode& node, String& value, const String& default_value)
73967396
value = !node.node ? default_value : CV_NODE_IS_STRING(node.node->tag) ? String(node.node->data.str.ptr) : String();
73977397
}
73987398

7399+
void read(const FileNode& node, std::string& value, const std::string& default_value)
7400+
{
7401+
value = !node.node ? default_value : CV_NODE_IS_STRING(node.node->tag) ? std::string(node.node->data.str.ptr) : default_value;
7402+
}
7403+
73997404
}
74007405

74017406

0 commit comments

Comments
 (0)