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

Function icvXMLWriteString

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

Source from the content-addressed store, hash-verified

2525
2526
2527static void
2528icvXMLWriteString( CvFileStorage* fs, const char* key, const char* str, int quote )
2529{
2530 char buf[CV_FS_MAX_LEN*6+16];
2531 char* data = (char*)str;
2532 int i, len;
2533
2534 if( !str )
2535 CV_Error( CV_StsNullPtr, "Null string pointer" );
2536
2537 len = (int)strlen(str);
2538 if( len > CV_FS_MAX_LEN )
2539 CV_Error( CV_StsBadArg, "The written string is too long" );
2540
2541 if( quote || len == 0 || str[0] != '\"' || str[0] != str[len-1] )
2542 {
2543 int need_quote = quote || len == 0;
2544 data = buf;
2545 *data++ = '\"';
2546 for( i = 0; i < len; i++ )
2547 {
2548 char c = str[i];
2549
2550 if( (uchar)c >= 128 || c == ' ' )
2551 {
2552 *data++ = c;
2553 need_quote = 1;
2554 }
2555 else if( !cv_isprint(c) || c == '<' || c == '>' || c == '&' || c == '\'' || c == '\"' )
2556 {
2557 *data++ = '&';
2558 if( c == '<' )
2559 {
2560 memcpy(data, "lt", 2);
2561 data += 2;
2562 }
2563 else if( c == '>' )
2564 {
2565 memcpy(data, "gt", 2);
2566 data += 2;
2567 }
2568 else if( c == '&' )
2569 {
2570 memcpy(data, "amp", 3);
2571 data += 3;
2572 }
2573 else if( c == '\'' )
2574 {
2575 memcpy(data, "apos", 4);
2576 data += 4;
2577 }
2578 else if( c == '\"' )
2579 {
2580 memcpy( data, "quot", 4);
2581 data += 4;
2582 }
2583 else
2584 {

Callers

nothing calls this directly

Calls 2

cv_isdigitFunction · 0.85
icvXMLWriteScalarFunction · 0.85

Tested by

no test coverage detected