Extern/DXF/Header/libdwgr.cpp
/* Open the file and stores it in filestr, install the correct reader version.
 * If fail opening file, error are set as DRW::BAD_OPEN
 * If not are DWG or are unsupported version, error are set as DRW::BAD_VERSION
 * and closes filestr.
 * Return true on succeed or false on fail
*/
Open the file and stores it in filestr, install the correct reader version.
If fail opening file, error are set as DRW::BAD_OPEN
If not are DWG or are unsupported version, error are set as DRW::BAD_VERSION
and closes filestr.
Return true on succeed or false on fail
Open the file and stores it in filestr install the correct reader version . If fail opening file error are set as DRW :: BAD_OPEN If not are DWG or are unsupported version error are set as DRW :: BAD_VERSION and closes filestr . Return true on succeed or false on fail
bool dwgR::openFile(std::ifstream *filestr){
    bool isOk = false;
    DRW_DBG("dwgR::read 1\n");
    filestr->open (fileName.c_str(), std::ios_base::in | std::ios::binary);
    if (!filestr->is_open() || !filestr->good() ){
        error = DRW::BAD_OPEN;
        return isOk;
    }
    char line[7];
    filestr->read (line, 6);
    line[6]='\0';
    DRW_DBG("dwgR::read 2\n");
    DRW_DBG("dwgR::read line version: ");
    DRW_DBG(line);
    DRW_DBG("\n");
    if (strcmp(line, "AC1006") == 0)
        version = DRW::AC1006;
    else if (strcmp(line, "AC1009") == 0) {
        version = DRW::AC1009;
    }else if (strcmp(line, "AC1012") == 0){
        version = DRW::AC1012;
        reader = new dwgReader15(filestr, this);
    } else if (strcmp(line, "AC1014") == 0) {
        version = DRW::AC1014;
        reader = new dwgReader15(filestr, this);
    } else if (strcmp(line, "AC1015") == 0) {
        version = DRW::AC1015;
        reader = new dwgReader15(filestr, this);
    } else if (strcmp(line, "AC1018") == 0){
        version = DRW::AC1018;
        reader = new dwgReader18(filestr, this);
    } else if (strcmp(line, "AC1021") == 0) {
        version = DRW::AC1021;
        reader = new dwgReader21(filestr, this);
    } else if (strcmp(line, "AC1024") == 0) {
        version = DRW::AC1024;
        reader = new dwgReader24(filestr, this);
    } else if (strcmp(line, "AC1027") == 0) {
        version = DRW::AC1027;
        reader = new dwgReader27(filestr, this);
    } else
        version = DRW::UNKNOWNV;
    if (reader == NULL) {
        error = DRW::BAD_VERSION;
        filestr->close();
    } else
        isOk = true;
    return isOk;
}
bool dwgR :: openFile ( std :: ifstream * filestr ) { bool isOk = false ; DRW_DBG ( " \n " ) ; filestr -> open ( fileName . c_str ( ) , std :: ios_base :: in | std :: ios :: binary ) ; if ( ! filestr -> is_open ( ) || ! filestr -> good ( ) ) { error = DRW :: BAD_OPEN ; return isOk ; } char line [ 7 ] ; filestr -> read ( line , 6 ) ; line [ 6 ] = ' \0 ' ; DRW_DBG ( " \n " ) ; DRW_DBG ( " " ) ; DRW_DBG ( line ) ; DRW_DBG ( " \n " ) ; if ( strcmp ( line , " " ) == 0 ) version = DRW :: AC1006 ; else if ( strcmp ( line , " " ) == 0 ) { version = DRW :: AC1009 ; } else if ( strcmp ( line , " " ) == 0 ) { version = DRW :: AC1012 ; reader = new dwgReader15 ( filestr , this ) ; } else if ( strcmp ( line , " " ) == 0 ) { version = DRW :: AC1014 ; reader = new dwgReader15 ( filestr , this ) ; } else if ( strcmp ( line , " " ) == 0 ) { version = DRW :: AC1015 ; reader = new dwgReader15 ( filestr , this ) ; } else if ( strcmp ( line , " " ) == 0 ) { version = DRW :: AC1018 ; reader = new dwgReader18 ( filestr , this ) ; } else if ( strcmp ( line , " " ) == 0 ) { version = DRW :: AC1021 ; reader = new dwgReader21 ( filestr , this ) ; } else if ( strcmp ( line , " " ) == 0 ) { version = DRW :: AC1024 ; reader = new dwgReader24 ( filestr , this ) ; } else if ( strcmp ( line , " " ) == 0 ) { version = DRW :: AC1027 ; reader = new dwgReader27 ( filestr , this ) ; } else version = DRW :: UNKNOWNV ; if ( reader == NULL ) { error = DRW :: BAD_VERSION ; filestr -> close ( ) ; } else isOk = true ; return isOk ; }
Open the file and stores it in filestr, install the correct reader version.
Open the file and stores it in filestr install the correct reader version .
//        reader = new dwgReader09(&filestr, this);