MCPcopy Create free account
hub / github.com/creatale/node-dv / getDefaultObjectName

Method getDefaultObjectName

deps/opencv/modules/core/src/persistence.cpp:119–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

117}
118
119cv::string cv::FileStorage::getDefaultObjectName(const string& _filename)
120{
121 static const char* stubname = "unnamed";
122 const char* filename = _filename.c_str();
123 const char* ptr2 = filename + _filename.size();
124 const char* ptr = ptr2 - 1;
125 cv::AutoBuffer<char> name_buf(_filename.size()+1);
126
127 while( ptr >= filename && *ptr != '\\' && *ptr != '/' && *ptr != ':' )
128 {
129 if( *ptr == '.' && (!*ptr2 || strncmp(ptr2, ".gz", 3) == 0) )
130 ptr2 = ptr;
131 ptr--;
132 }
133 ptr++;
134 if( ptr == ptr2 )
135 CV_Error( CV_StsBadArg, "Invalid filename" );
136
137 char* name = name_buf;
138
139 // name must start with letter or '_'
140 if( !cv_isalpha(*ptr) && *ptr!= '_' ){
141 *name++ = '_';
142 }
143
144 while( ptr < ptr2 )
145 {
146 char c = *ptr++;
147 if( !cv_isalnum(c) && c != '-' && c != '_' )
148 c = '_';
149 *name++ = c;
150 }
151 *name = '\0';
152 name = name_buf;
153 if( strcmp( name, "_" ) == 0 )
154 strcpy( name, stubname );
155 return cv::string(name);
156}
157
158namespace cv
159{

Callers

nothing calls this directly

Calls 5

cv_isalphaFunction · 0.85
cv_isalnumFunction · 0.85
stringFunction · 0.85
c_strMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected