Advertisement
Guest User

Untitled

a guest
Dec 11th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. /*
  2. BuildInformation info;
  3. std::cout << info.getValue( "JPEG" ) << std::endl; // build (ver 90)
  4. */
  5.  
  6. #ifndef __BUILD_INFORMATION__
  7. #define __BUILD_INFORMATION__
  8.  
  9. #include <string>
  10. #include <sstream>
  11. #include <opencv2/opencv.hpp>
  12.  
  13. class BuildInformation
  14. {
  15. private:
  16. std::stringstream stream;
  17.  
  18. public:
  19. BuildInformation() : stream( cv::getBuildInformation() )
  20. {}
  21.  
  22. ~BuildInformation()
  23. {
  24. stream.str( "" );
  25. }
  26.  
  27. std::string getValue( const std::string& key )
  28. {
  29. std::string buffer;
  30. while( std::getline( stream, buffer ) ){
  31. std::string::size_type position;
  32. position = buffer.find( key + ":" );
  33. if( position == std::string::npos ){ continue; }
  34. position = buffer.find_first_not_of( " ", position + key.length() + 1 );
  35. if( position == std::string::npos ){ continue; }
  36. return buffer.substr( position );
  37. }
  38. return "";
  39. }
  40. };
  41.  
  42. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement