Пример #1
0
 virtual const std::string do_type() const throw ()
 {
     //
     // A real application should use OS facilities for this.  This
     // is a crude hack.
     //
     using std::find;
     using std::string;
     using boost::algorithm::iequals;
     using boost::next;
     string media_type = "application/octet-stream";
     const string::const_reverse_iterator dot_pos =
         find(this->url_.rbegin(), this->url_.rend(), '.');
     if (dot_pos == this->url_.rend()
             || next(dot_pos.base()) == this->url_.end()) {
         return media_type;
     }
     const string::const_iterator hash_pos =
         find(next(dot_pos.base()), this->url_.end(), '#');
     const string ext(dot_pos.base(), hash_pos);
     if (iequals(ext, "wrl")) {
         media_type = "model/vrml";
     } else if (iequals(ext, "x3dv")) {
         media_type = "model/x3d+vrml";
     } else if (iequals(ext, "png")) {
         media_type = "image/png";
     } else if (iequals(ext, "jpg") || iequals(ext, "jpeg")) {
         media_type = "image/jpeg";
     }
     return media_type;
 }
Пример #2
0
		virtual const std::string do_type() const throw ()
		{
			//
			// A real application should use OS facilities for this.  This
            // is a crude hack because sdl-viewer uses std::filebuf in
            // order to remain simple and portable.
			//
			using std::find;
			using std::string;
			using boost::algorithm::iequals;
			using boost::next;
			string media_type = "application/octet-stream";
			const string::const_reverse_iterator dot_pos =
				find(this->url_.rbegin(), this->url_.rend(), '.');
			if (dot_pos == this->url_.rend()
				|| next(dot_pos.base()) == this->url_.end()) {
				return media_type;
			}
			const string::const_iterator hash_pos =
				find(next(dot_pos.base()), this->url_.end(), '#');
			const string ext(dot_pos.base(), hash_pos);
			if (iequals(ext, "wrl")) {
                media_type = openvrml::vrml_media_type;
			} else if (iequals(ext, "x3dv")) {
                media_type = openvrml::x3d_vrml_media_type;
			} else if (iequals(ext, "png")) {
				media_type = "image/png";
			} else if (iequals(ext, "jpg") || iequals(ext, "jpeg")) {
				media_type = "image/jpeg";
			}
			return media_type;
		}