Difference between revisions of "CoreInterface PrintTitle Example"

From BRL-CAD
(New page: #include <iostream> #include <brlcad/ConstDatabase.h> int main ( int argc, char* argv[] ) { int ret = 0; if (argc < 2) { std::cout << "Usage: " ...)
 
m
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
 +
[[category:Code examples]]
 +
 
  #include <iostream>
 
  #include <iostream>
 
   
 
   
Line 26: Line 28:
 
             }
 
             }
 
         }
 
         }
         catch(std::bad_alloc e) {
+
         catch(BRLCAD::bad_alloc& e) {
 
             std::cout << "Out of memory in: " << e.what();
 
             std::cout << "Out of memory in: " << e.what();
 
             ret = 3;
 
             ret = 3;

Latest revision as of 09:48, 15 November 2009


#include <iostream>

#include <brlcad/ConstDatabase.h>


int main
(
    int   argc,
    char* argv[]
) {
    int ret = 0;

    if (argc < 2) {
        std::cout << "Usage: " << argv[0] << " <BRL-CAD Database>";
        ret = 1;
    }
    else {
        try {
            BRLCAD::ConstDatabase database;

            if (database.Load(argv[1]))
                std::cout << database.Title();
            else {
                std::cout << "Could not load file: " << argv[1];
                ret = 2;
            }
        }
        catch(BRLCAD::bad_alloc& e) {
            std::cout << "Out of memory in: " << e.what();
            ret = 3;
        }
    }

    return ret;
}