MCPcopy Create free account
hub / github.com/PDAL/PDAL / pathNameParse

Method pathNameParse

plugins/e57/libE57Format/src/ImageFileImpl.cpp:583–663  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

581 }
582
583 void ImageFileImpl::pathNameParse( const ustring &pathName, bool &isRelative,
584 StringList &fields )
585 {
586#ifdef E57_VERBOSE
587 std::cout << "pathNameParse pathname="
588 ""
589 << pathName
590 << ""
591 ""
592 << std::endl;
593#endif
594 // no checkImageFileOpen(__FILE__, __LINE__, __FUNCTION__)
595
596 // Clear previous contents of fields vector
597 fields.clear();
598
599 size_t start = 0;
600
601 // Check if absolute path
602 if ( pathName[start] == '/' )
603 {
604 isRelative = false;
605 start = 1;
606 }
607 else
608 {
609 isRelative = true;
610 }
611
612 // Save strings in between each forward slash '/'
613 // Don't ignore whitespace
614 while ( start < pathName.size() )
615 {
616 size_t slash = pathName.find_first_of( '/', start );
617
618 // Get element name from in between '/', check valid
619 ustring elementName = pathName.substr( start, slash - start );
620
621 if ( !isElementNameLegal( elementName ) )
622 {
623 throw E57_EXCEPTION2( ErrorBadPathName, std::string( "pathName=" )
624 .append( pathName )
625 .append( " elementName=" )
626 .append( elementName ) );
627 }
628
629 // Add to list
630 fields.push_back( elementName );
631
632 if ( slash == std::string::npos )
633 {
634 break;
635 }
636
637 // Handle case when pathname ends in /, e.g. "/foo/", add empty field at end of list
638 if ( slash == pathName.size() - 1 )
639 {
640 fields.emplace_back( "" );

Callers 3

lookupMethod · 0.80
setMethod · 0.80

Calls 4

clearMethod · 0.45
sizeMethod · 0.45
appendMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected