void aphexContentAscii(aphexWin *win) { char line[APHEX_WIN_ASCII_WIDTH] = { ' ' }; unsigned long offset = 0; for (unsigned long i=0; i<win->height; i++) { for (unsigned long j=0; j<8; j++) { offset = i*16 + j + 16*buf.shiftOffset; if (offset > buf.memsize-1) { snprintf(&(line[j]), 2, " "); } else { snprintf(&(line[j]), 2, "%c", c2a(buf.mem[offset])); } } strncpy(&(line[8]), " ", 1); for (unsigned long j=0; j<8; j++) { offset = i*16 + j + 8 + 16*buf.shiftOffset; if ((i*16+j + 8 + buf.shiftOffset*16) > buf.memsize-1) { snprintf(&(line[j+8+1]), 2, " "); } else { snprintf(&(line[j+8+1]), 2, "%c", c2a(buf.mem[offset])); } } strncpy(&(win->c[i*win->width]), line, win->width); } aphexWinToWin(&winBase, &winAscii); }
int main(int argc, char ** argv) { ISvcLocator *svc = NULL; std::cout << "Looking for classes..." << std::endl; std::auto_ptr<MyInterface> c1a( AlgFactory_t::create("Class1", "c1a", svc) ); std::auto_ptr<MyInterface> c2a( AlgFactory_t::create("Class2", "c2a", svc) ); call(c1a.get()); call(c2a.get()); std::cout << "Looking for IDs..." << std::endl; std::auto_ptr<MyInterface> c1b( AlgFactory_t::create("1", "c1b", svc) ); std::auto_ptr<MyInterface> c2b( AlgFactory_t::create("2", "c2b", svc) ); call(c1b.get()); call(c2b.get()); try { AlgFactory_t::create("3", "c1b", svc); } catch (Gaudi::PluginService::Exception &e) { std::cout << "PluginService::Exception -> " << e.what() << std::endl; } std::cout << "Done!" << std::endl; }
void test_bytevec() { // TODO: check the number of reallocations bytevec c1; check(c1.begin() == NULL); check(c1.empty()); check(c1._isunique()); check(c1.size() == 0); check(c1.capacity() == 0); bytevec c2("ABC", 3); check(!c2.empty()); check(c2.size() == 3); check(c2.capacity() == 3); check(c1._isunique()); check(c2._isunique()); c1 = c2; check(!c2._isunique()); check(!c1._isunique()); c2.clear(); check(c1._isunique()); check(c2._isunique()); check(c2.empty()); check(!c1.empty()); check(c1.size() == 3); c1 = c1; c2 = c1; check(!c2._isunique()); check(!c1._isunique()); *c2.atw(0) = 'a'; check(c2._isunique()); check(c1._isunique()); check(c2.data()[0] == 'a'); check(c1.data()[0] == 'A'); *c2.atw(0) = 'A'; check(c2.data()[0] == 'A'); bytevec c2a("", 0); check(c2a.begin() == NULL); check(c2a.empty()); check(c2a.size() == 0); check(c2a.capacity() == 0); bytevec c3("DEFG", 4); c1.insert(3, c3); check(c1._isunique()); check(c1.size() == 7); check(c1.capacity() > 7); check(memcmp(c1.data(), "ABCDEFG", 7) == 0); bytevec c4 = c1; check(!c1._isunique()); c1.insert(3, "ab", 2); check(c1._isunique()); check(c1.size() == 9); check(c1.capacity() == 9); check(memcmp(c1.data(), "ABCabDEFG", 9) == 0); c1.insert(0, "@", 1); check(c1._isunique()); check(c1.size() == 10); check(memcmp(c1.data(), "@ABCabDEFG", 10) == 0); c1.insert(10, "0123456789", 10); check(c1.size() == 20); check(memcmp(c1.data(), "@ABCabDEFG0123456789", 20) == 0); c2.append(c2); check(memcmp(c2.data(), "ABCABC", 6) == 0); check(c2.size() == 6); c2.append("abcd", 4); check(c2.size() == 10); check(memcmp(c2.data(), "ABCABCabcd", 10) == 0); c4 = c2; check(!c2._isunique()); c2.append(c3); check(c2._isunique()); check(c2.size() == 14); check(memcmp(c2.data(), "ABCABCabcdDEFG", 14) == 0); c1.erase(4, 2); check(memcmp(c1.data(), "@ABCDEFG0123456789", 18) == 0); c4 = c1; c1.erase(8, 5); check(c1.size() == 13); check(memcmp(c1.data(), "@ABCDEFG56789", 13) == 0); c1.erase(8, 5); check(c1.size() == 8); check(memcmp(c1.data(), "@ABCDEFG", 8) == 0); c1.pop(2); check(c1.size() == 6); check(memcmp(c1.data(), "@ABCDE", 6) == 0); c1.pop(2); check(c1.size() == 4); c1.pop(4); check(c1.empty()); c1.append("@AB", 3); check(c1.size() == 3); check(memcmp(c1.data(), "@AB", 3) == 0); c1.resize(6, '!'); check(c1.size() == 6); check(memcmp(c1.data(), "@AB!!!", 3) == 0); c1.resize(0); check(c1.empty()); check(c1.begin() == NULL); }