Changeset 9884
- Timestamp:
- 03/10/09 13:21:13 (4 years ago)
- Location:
- OpenSceneGraph/trunk
- Files:
-
- 5 modified
-
include/osgDB/FileNameUtils (modified) (1 diff)
-
include/osgDB/Registry (modified) (3 diffs)
-
src/osgDB/FileNameUtils.cpp (modified) (2 diffs)
-
src/osgDB/ReaderWriter.cpp (modified) (1 diff)
-
src/osgDB/Registry.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/include/osgDB/FileNameUtils
r8912 r9884 41 41 42 42 extern OSGDB_EXPORT bool containsServerAddress(const std::string& filename); 43 extern OSGDB_EXPORT std::string getServerProtocol(const std::string& filename); 43 44 extern OSGDB_EXPORT std::string getServerAddress(const std::string& filename); 44 45 extern OSGDB_EXPORT std::string getServerFileName(const std::string& filename); -
OpenSceneGraph/trunk/include/osgDB/Registry
r9334 r9884 479 479 /** Add an Archive extension.*/ 480 480 void addArchiveExtension(const std::string ext); 481 481 482 /** registers a protocol */ 483 void registerProtocol(const std::string& protocol); 484 485 /** returns true, if named protocol is registered */ 486 bool isProtocolRegistered(const std::string& protocol); 487 482 488 protected: 483 489 … … 492 498 typedef std::map<std::string, ObjectTimeStampPair > ObjectCache; 493 499 typedef std::map<std::string, osg::ref_ptr<osgDB::Archive> > ArchiveCache; 500 501 typedef std::set<std::string> RegisteredProtocolsSet; 494 502 495 503 /** constructor is private, as its a singleton, preventing … … 509 517 510 518 bool _createNodeFromImage; 519 520 RegisteredProtocolsSet _registeredProtocols; 511 521 512 522 osg::Object* readObject(DotOsgWrapperMap& dowMap,Input& fr); -
OpenSceneGraph/trunk/src/osgDB/FileNameUtils.cpp
r8912 r9884 180 180 } 181 181 182 183 182 184 bool osgDB::containsServerAddress(const std::string& filename) 183 185 { 184 // need to check for http:// 185 if (filename.size()<7) return false; 186 if (filename.compare(0,7,"http://")==0) return true; 187 return false; 186 // need to check for :// 187 std::string::size_type pos(filename.find_first_of("://")); 188 if (pos == std::string::npos) 189 return false; 190 std::string proto(filename.substr(0, pos)); 191 192 return Registry::instance()->isProtocolRegistered(proto); 193 } 194 195 std::string osgDB::getServerProtocol(const std::string& filename) 196 { 197 std::string::size_type pos(filename.find_first_of("://")); 198 if (pos != std::string::npos) 199 return filename.substr(0,pos); 200 201 return ""; 188 202 } 189 203 190 204 std::string osgDB::getServerAddress(const std::string& filename) 191 205 { 192 if (filename.size()>=7 && filename.compare(0,7,"http://")==0) 193 { 194 std::string::size_type pos_slash = filename.find_first_of('/',7); 206 std::string::size_type pos(filename.find_first_of("://")); 207 208 if (pos != std::string::npos) 209 { 210 std::string::size_type pos_slash = filename.find_first_of('/',pos+3); 195 211 if (pos_slash!=std::string::npos) 196 212 { 197 return filename.substr( 7,pos_slash-7);213 return filename.substr(pos+3,pos_slash-pos-3); 198 214 } 199 215 else 200 216 { 201 return filename.substr( 7,std::string::npos);217 return filename.substr(pos+3,std::string::npos); 202 218 } 203 219 } … … 207 223 std::string osgDB::getServerFileName(const std::string& filename) 208 224 { 209 if (filename.size()>=7 && filename.compare(0,7,"http://")==0) 210 { 211 std::string::size_type pos_slash = filename.find_first_of('/',7); 225 std::string::size_type pos(filename.find_first_of("://")); 226 227 if (pos != std::string::npos) 228 { 229 std::string::size_type pos_slash = filename.find_first_of('/',pos+3); 212 230 if (pos_slash!=std::string::npos) 213 231 { -
OpenSceneGraph/trunk/src/osgDB/ReaderWriter.cpp
r8620 r9884 48 48 void ReaderWriter::supportsProtocol(const std::string& fmt, const std::string& description) 49 49 { 50 Registry::instance()->registerProtocol(fmt); 50 51 _supportedProtocols[convertToLowerCase(fmt)] = description; 51 52 } -
OpenSceneGraph/trunk/src/osgDB/Registry.cpp
r9881 r9884 331 331 addFileExtensionAlias("pgm", "pnm"); 332 332 addFileExtensionAlias("ppm", "pnm"); 333 334 // register http-protocol, so the curl can handle it, if necessary 335 registerProtocol("http"); 333 336 334 337 } … … 2093 2096 return _sharedStateManager.get(); 2094 2097 } 2098 2099 2100 void Registry::registerProtocol(const std::string& protocol) 2101 { 2102 _registeredProtocols.insert( convertToLowerCase(protocol) ); 2103 } 2104 2105 bool Registry::isProtocolRegistered(const std::string& protocol) 2106 { 2107 return (_registeredProtocols.find( convertToLowerCase(protocol) ) != _registeredProtocols.end()); 2108 } 2109
