示例#1
0
int main(int argc, const char * argv[])
{
	BWString filename;
	DIR * dir = nullptr;

	if (filepath.last_char() != '/') {
		filepath += "/";
	}

	JPEGData ref_jpeg = filepath + ref_file;
	if(!ref_jpeg.read_jpeg()) {
	    return 1;
	}

	struct dirent * dirp = nullptr;
	dir = opendir(filepath.c_str());
	if (dir == nullptr) {
		printf("cannot open directory %s (%s)\n", filepath.c_str(), strerror(errno));
		return 1;
	}

	while ((dirp = readdir(dir)) != nullptr) {
		BWString dfilename = dirp->d_name;

		if(*dirp->d_name == '.') continue;
		if(ref_file == dfilename) continue;

		JPEGData * j = new JPEGData(filepath + dfilename);
        if(!j->read_jpeg()) {
            return 1;
        }

		const JPEGData::coords *rc = ref_jpeg.find(j);
		if (rc) {
			printf("--> %s (%d x %d): match! (%d x %d)\n", dfilename.c_str(), j->width(), j->height(), rc->x, rc->y);
		} else {
			printf("%s (%d x %d): no match\n", dfilename.c_str(), j->width(), j->height());
		}
		delete j;
	}

	if(dir) closedir(dir);
	return 0;
}
示例#2
0
bool BWDB::prepare_query(const BWString &sQuery, const std::vector<BWString> &vParams)
{
    _clear_value();
    const char *q = sQuery.c_str();
    if (sqlite3_prepare_v2(_dbh, q, -1, &stmt, NULL) != SQLITE_OK)
    {
        _finalize();
        return false;
    }
    for (unsigned int i = 0; i < vParams.size(); ++i)
    {
        sqlite3_bind_text(stmt, i + 1, vParams[i].c_str(), -1, SQLITE_TRANSIENT);
    }

    return true;
}
示例#3
0
BWString BWDB::get_query_value(const BWString &q)
{
    _clear_value();
    if (sqlite3_prepare_v2(_dbh, q.c_str(), -1, &stmt, NULL) != SQLITE_OK)
    {
        _finalize();
        return _value;
    }
    if (sqlite3_step(stmt) == SQLITE_ROW)
    {
        char *rc = (char *) sqlite3_column_text(stmt, 0);
        if (rc) _set_value(rc);
    }
    _finalize();
    return _value;
}
示例#4
0
BWString BWDB::get_query_value(const BWString &sQuery, const std::vector<BWString> &vParams)
{
    _clear_value();
    const char *q = sQuery.c_str();
    if (sqlite3_prepare_v2(_dbh, q, -1, &stmt, NULL) != SQLITE_OK)
    {
        _finalize();
        _get_value();
    }
    for (unsigned int i = 0; i < vParams.size(); ++i)
    {
        sqlite3_bind_text(stmt, i + 1, vParams[i].c_str(), -1, SQLITE_TRANSIENT);
    }

    if (sqlite3_step(stmt) == SQLITE_ROW)
    {
        char *rc = (char *) sqlite3_column_text(stmt, 0);
        if (rc) _set_value(rc);
    }
    _finalize();
    return _get_value();
}
示例#5
0
bool BWDB::do_query(const BWString &sQuery, const std::vector<BWString> &params)
{
    const char *q = sQuery.c_str();
    if (sqlite3_prepare_v2(_dbh, q, -1, &stmt, NULL) != SQLITE_OK)
    {
        _finalize();
        return false;
    }
    for (unsigned int i = 0; i < params.size(); ++i)
    {
        sqlite3_bind_text(stmt, i + 1, params[i].c_str(), -1, SQLITE_TRANSIENT);
    }

    if (sqlite3_step(stmt) == SQLITE_ROW)
    {
        _set_value((const char *) sqlite3_column_text(stmt, 0));
        _finalize();
        return true;
    } else
    {
        _finalize();
        return false;
    }
}
示例#6
0
文件: BWCGI.cpp 项目: cy2296/coding
void BWCGI::disp_page( const BWString & type, const BWString & s ) {
	BWString buf = _content_type + ": " + type + _crlf + _crlf + s;
	fputs(buf.c_str(), stdout);
}
示例#7
0
bool BWString::operator != ( const BWString & rhs ) const {
    if( std::strncmp(this->c_str(), rhs.c_str(), __BWString__MAX_LEN) != 0 ) return true;
    else return false;
}
示例#8
0
文件: BWKV.cpp 项目: cy2296/coding
void BWKV::del( const BWString & key ) {
		del(key.c_str());
}
示例#9
0
文件: BWKV.cpp 项目: cy2296/coding
const BWString BWKV::operator [] ( const BWString & key ) {
	return BWString(value( key.c_str() ));
}
示例#10
0
bool BWDB::do_query(const BWString &q)
{
    return do_query(q.c_str());
}