less-than operator overloader for a long array

  • (2 Pages)
  • +
  • 1
  • 2

21 Replies - 477 Views - Last Post: 21 November 2012 - 08:25 AM Rate Topic: -----

#16 DJViking  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 25
  • Joined: 07-November 12

Re: less-than operator overloader for a long array

Posted 20 November 2012 - 07:33 AM

Changed the test slightly:

int main(int argc, char **argv) {

	cout << "Testing first set of OID" << endl;
	const oid oid1[] = { 1,3,6,1,4,1,40850,1,3 };
	const oid_wrapper parent1 (oid1, 9);
	const oid_wrapper parent1_child1 (parent1, 40);
	const oid_wrapper parent1_child2 (parent1, 41);
	const oid_wrapper parent1_child3 (parent1, 42);
	const oid_wrapper parent1_child4 (parent1, 43);

	map<oid_wrapper, string> test;
	test.insert(make_pair(parent1_child1, "parent1_child1"));
	test.insert(make_pair(parent1_child2, "parent1_child2"));
	test.insert(make_pair(parent1_child3, "parent1_child3"));
	test.insert(make_pair(parent1_child4, "parent1_child4"));
	if (test.size() != 4) { cout << "FAIL" << endl; }
	cout << "Number of OID in list: " << test.size() << endl;

	const oid_wrapper parent11 (oid1, 9);
	const oid_wrapper parent1_child11 (parent11, 40);
	try {
		string teststring = test.at(parent1_child11);
		cout << "Success" << endl;
	} catch (out_of_range& e) {
		cout << "Failure" << endl;
	}

	const oid_wrapper parent1_child12 (parent11, 41);
	try {
		string teststring = test.at(parent1_child12);
		cout << "Success" << endl;
	} catch (out_of_range& e) {
		cout << "Failure" << endl;
	}

	const oid_wrapper parent1_child13 (parent11, 42);
	try {
		string teststring = test.at(parent1_child13);
		cout << "Success" << endl;
	} catch (out_of_range& e) {
		cout << "Failure" << endl;
	}

	const oid_wrapper parent1_child14 (parent11, 43);
	try {
		string teststring = test.at(parent1_child14);
		cout << "Success" << endl;
	} catch (out_of_range& e) {
		cout << "Failure" << endl;
	}

	cout << "Testing second set of OID" << endl;
	const oid oid2[] = { 1,3,6,1,4,1,40850,2,1,9,1 };
	const oid_wrapper parent2 (oid2, 11);
	const oid_wrapper parent2_child1 (parent2, 1);
	const oid_wrapper parent2_child2 (parent2, 2);
	const oid_wrapper parent2_child3 (parent2, 3);
	const oid_wrapper parent2_child4 (parent2, 4);

	test.insert(make_pair(parent2_child1, "parent2_child1"));
	test.insert(make_pair(parent2_child2, "parent2_child2"));
	test.insert(make_pair(parent2_child3, "parent2_child3"));
	test.insert(make_pair(parent2_child4, "parent2_child4"));
	if (test.size() != 8) { cout << "FAIL" << endl; }
	cout << "Number of OID in list: " << test.size() << endl;

	const oid_wrapper parent21 (oid2, 11);
	const oid_wrapper parent1_child21 (parent21, 1);
	try {
		string teststring = test.at(parent1_child21);
		cout << "Success" << endl;
	} catch (out_of_range& e) {
		cout << "Failure" << endl;
	}

	const oid_wrapper parent1_child22 (parent21, 2);
	try {
		string teststring = test.at(parent1_child22);
		cout << "Success" << endl;
	} catch (out_of_range& e) {
		cout << "Failure" << endl;
	}

	const oid_wrapper parent1_child23 (parent21, 3);
	try {
		string teststring = test.at(parent1_child23);
		cout << "Success" << endl;
	} catch (out_of_range& e) {
		cout << "Failure" << endl;
	}

	const oid_wrapper parent1_child24 (parent21, 4);
	try {
		string teststring = test.at(parent1_child24);
		cout << "Success" << endl;
	} catch (out_of_range& e) {
		cout << "Failure" << endl;
	}

	//#################################################

	//Adding 100 OIDs
	for (int i = 0; i < 100; i++) {
		const oid newoid[] = { 1,3,6,1,4,1,40850,2,4,9,1 };
		const oid_wrapper wrapper(newoid, 11, i);
		test.insert(make_pair(wrapper, "wrapper"));
	}

	//Query for the 100 added OIDs
	int run1 = 0;
	for (int i = 0; i < 100; i++) {
		const oid newoid[] = { 1,3,6,1,4,1,40850,2,4,9,1 };
		const oid_wrapper wrapper(newoid, 11, i);

		std::map<oid_wrapper, string>::iterator iter = test.find(wrapper);
		if (iter != test.end()) {
			run1++;
		}
	}
	cout << "Run 1: " << run1 << endl;

	//#################################################

	//Adding 100 OIDs
	for (int i = 0; i < 100; i++) {
		const oid newoid[] = { 1,3,6,1,4,1,40850,1,4 };
		const oid_wrapper wrapper(newoid, 9, i);
		test.insert(make_pair(wrapper, "wrapper"));
	}

	//Query for the 100 added OIDs
	int run2 = 0;
	for (int i = 0; i < 100; i++) {
		const oid newoid[] = { 1,3,6,1,4,1,40850,1,4 };
		const oid_wrapper wrapper(newoid, 9, i);

		std::map<oid_wrapper, string>::iterator iter = test.find(wrapper);
		if (iter != test.end()) {
			run2++;
		}
	}
	cout << "Run 2: " << run2 << endl;

	//#################################################

	//Adding 100 OIDs
	for (int i = 0; i < 100; i++) {
		const oid newoid[] = { 1,3,6,1,4,1,40850,2 };
		const oid_wrapper wrapper(newoid, 8, i);
		test.insert(make_pair(wrapper, "wrapper"));
	}

	//Query for the 100 added OIDs
	int run3 = 0;
	for (int i = 0; i < 100; i++) {
		const oid newoid[] = { 1,3,6,1,4,1,40850,2 };
		const oid_wrapper wrapper(newoid, 8, i);

		std::map<oid_wrapper, string>::iterator iter = test.find(wrapper);
		if (iter != test.end()) {
			run3++;
		}
	}
	cout << "Run 3: " << run3 << endl;

	//#################################################

	//Adding 500 OIDs
	for (int i = 0; i < 100; i++) {
		const oid newoid[] = { 1,3,6,1,4,1,40850,2,2,5,1 };
		const oid_wrapper wrapper(newoid, 11, i);
		test.insert(make_pair(wrapper, "wrapper"));
	}

	//Query for the 500 added OIDs
	int run4 = 0;
	for (int i = 0; i < 100; i++) {
		const oid newoid[] = { 1,3,6,1,4,1,40850,2,2,5,1 };
		const oid_wrapper wrapper(newoid, 11, i);

		std::map<oid_wrapper, string>::iterator iter = test.find(wrapper);
		if (iter != test.end()) {
			run4++;
		}
	}
	cout << "Run 4: " << run4 << endl;

	//#################################################

	//Adding 500 OIDs
	for (int i = 0; i < 100; i++) {
		const oid newoid[] = { 1,3,6,1,4,1,40850,2,3,5,2 };
		const oid_wrapper wrapper(newoid, 11, i);
		test.insert(make_pair(wrapper, "wrapper"));
	}

	//Query for the 500 added OIDs
	int run5 = 0;
	for (int i = 0; i < 100; i++) {
		const oid newoid[] = { 1,3,6,1,4,1,40850,2,3,5,2 };
		const oid_wrapper wrapper(newoid, 11, i);

		std::map<oid_wrapper, string>::iterator iter = test.find(wrapper);
		if (iter != test.end()) {
			run5++;
		}
	}
	cout << "Run 5: " << run5 << endl;

	//#################################################

	//Adding 500 OIDs
	for (int i = 0; i < 100; i++) {
		const oid newoid[] = { 1,3,6,1,4,1,40850,2,2,5,2 };
		const oid_wrapper wrapper(newoid, 10, i);
		test.insert(make_pair(wrapper, "wrapper"));
	}

	//Query for the 500 added OIDs
	int run6 = 0;
	for (int i = 0; i < 100; i++) {
		const oid newoid[] = { 1,3,6,1,4,1,40850,2,2,5,2 };
		const oid_wrapper wrapper(newoid, 10, i);

		std::map<oid_wrapper, string>::iterator iter = test.find(wrapper);
		if (iter != test.end()) {
			run6++;
		}
	}
	cout << "Run 6: " << run6 << endl;


	//#################################################

	//Adding 500 OIDs
	for (int i = 0; i < 100; i++) {
		const oid newoid[] = { 1,3,6,1,4,1,40850,2,5,2,3,5 };
		const oid_wrapper wrapper(newoid, 12, i);
		test.insert(make_pair(wrapper, "wrapper"));
	}

	//Query for the 500 added OIDs
	int run7 = 0;
	for (int i = 0; i < 100; i++) {
		const oid newoid[] = { 1,3,6,1,4,1,40850,2,5,2,3,5 };
		const oid_wrapper wrapper(newoid, 12, i);

		std::map<oid_wrapper, string>::iterator iter = test.find(wrapper);
		if (iter != test.end()) {
			run7++;
		}
	}
	cout << "Run 7: " << run7 << endl;

	cout << "Total in map " << test.size() << endl;
}




Output:
Testing first set of OID
Number of OID in list: 4
Success
Success
Success
Success
Testing second set of OID
Number of OID in list: 8
Success
Success
Success
Success
Run 1: 96
Run 2: 89
Run 3: 100
Run 4: 31
Run 5: 0
Run 6: 100
Run 7: 100
Total in map 708



The map contains 708 values. So if find/at worked all run1-7 should give 100 each.
Was This Post Helpful? 0
  • +
  • -

#17 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 5956
  • View blog
  • Posts: 23,226
  • Joined: 23-August 08

Re: less-than operator overloader for a long array

Posted 20 November 2012 - 08:35 AM

I think I got it. Your < must go through all the entries UNTIL it finds one >= the key.

I *think*.
Was This Post Helpful? 0
  • +
  • -

#18 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5643
  • View blog
  • Posts: 12,359
  • Joined: 16-October 07

Re: less-than operator overloader for a long array

Posted 20 November 2012 - 09:27 AM

You know, looking at the lib you're presubably using, there does seem to be a compare: http://www.net-snmp....mp_library.html

Also, you're leaking like a sieve.

Perhaps:
class oid_wrapper {
private:
	oid *oid_value; // don't think const means what you think it means
	int oid_length;
public:
	oid_wrapper(const oid* _oid_value, int _oid_length) : oid_value(0), oid_length(_oid_length) {
		oid_value = snmp_duplicate_objid(_oid_value, oid_length);
	}
	// STOP LEAKING MEMORY!!!
	~oid_wrapper() { if (oid_value!=0) { free(oid_value); } }

	// this is a bad idea.  Why not just give access to the value?
	// const oid *get_oid() const { return oid_value; }
	oid operator[](unsigned i) { return (i<oid_length) ? oid_value[i] : oid(); }
	
	int get_length() const { return oid_length; }

	oid_wrapper& operator=(const oid_wrapper& wrapper) {
		if (oid_value!=0) { free(oid_value); } // memory leak, fixed
		oid_value = snmp_duplicate_objid(wrapper.oid_value, wrapper.oid_length);
		oid_length = wrapper.oid_length;
		return *this;
	}
	
	int compare(const oid_wrapper& rhs) const {
		return snmp_oid_compare (oid_value, oid_length, rhs.oid_value, rhs.oid_length);
	}
	
	oid getLastNumberInOid() const { return oid_value[oid_length - 1]; }

	bool operator==(const oid_wrapper& rhs) const { return compare(rhs)==0; }
	bool operator<(const oid_wrapper& rhs) const { return compare(rhs)<0; }


	bool operator!=(const oid_wrapper& rhs) const { return compare(rhs)!=0; }
	bool operator>(const oid_wrapper& rhs) const { return compare(rhs)>0; }
	bool operator<=(const oid_wrapper& rhs) const { return compare(rhs)<=0; }
	bool operator>=(const oid_wrapper& rhs) const { return compare(rhs)>=0; }
	
	void print(std::ostream &out) const {
		for(int i = 0; i < oid_length; i++) {
			if (i != 0) { out << "."; }
			out << oid_value[i];
		}
		
	}

};

std::ostream& operator<<(std::ostream &output, const oid_wrapper &wrapper) {
	wrapper.print(output);
	return output;
}




Hope this helps.
Was This Post Helpful? 0
  • +
  • -

#19 DJViking  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 25
  • Joined: 07-November 12

Re: less-than operator overloader for a long array

Posted 20 November 2012 - 11:21 AM

baavgai: thanks. Will try it when I get back to work tomorrow.

I have mostly done programming in Java, so I'm a little spoiled by its garbage collector.

Have chosen to keep the oid array/pointer const because net-snmp always wants a const oid.


Edit: Finally the chance to edit my posts.

This post has been edited by DJViking: 20 November 2012 - 11:23 AM

Was This Post Helpful? 0
  • +
  • -

#20 DJViking  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 25
  • Joined: 07-November 12

Re: less-than operator overloader for a long array

Posted 21 November 2012 - 12:56 AM

View Postbaavgai, on 20 November 2012 - 09:27 AM, said:

You know, looking at the lib you're presubably using, there does seem to be a compare: http://www.net-snmp....mp_library.html

Also, you're leaking like a sieve.

Perhaps:




Hope this helps.


Excellent. Your suggestion on using snmp_oid_compare worked. I considered using it before, but don't remember my reservation for it. While using this compare functionality the operator< works perfectly, and so does the other operators.

Edit: Remember now why I didn't consider that compare: Previous read the documentation on netsnmp_oid_compare_ll and confused it with netsnmp_oid_compare.


However. I had to remove the use of free in the destructor. It wouldn't run with it.
Testing first set of OID
*** glibc detected *** ./testoid: double free or corruption (fasttop): 0x00000000025f7230 ***
======= Backtrace: =========
/lib64/libc.so.6(+0x78b56)[0x7f620863fb56]
./testoid[0x40146f]
/lib64/libc.so.6(__libc_start_main+0xf5)[0x7f62085e8455]
./testoid[0x403971]
======= Memory map: ========
00400000-00405000 r-xp 00000000 08:07 131190                             /home/POLAR/sverre/workspace/meos-snmp/src/testoid
00604000-00605000 r--p 00004000 08:07 131190                             /home/POLAR/sverre/workspace/meos-snmp/src/testoid
00605000-00606000 rw-p 00005000 08:07 131190                             /home/POLAR/sverre/workspace/meos-snmp/src/testoid
025f5000-02616000 rw-p 00000000 00:00 0                                  [heap]
7f62064db000-7f62064e2000 rw-p 00000000 00:00 0 
7f62064e2000-7f62064e6000 r-xp 00000000 08:06 2626799                    /lib64/libattr.so.1.1.0
7f62064e6000-7f62066e5000 ---p 00004000 08:06 2626799                    /lib64/libattr.so.1.1.0
7f62066e5000-7f62066e6000 r--p 00003000 08:06 2626799                    /lib64/libattr.so.1.1.0
7f62066e6000-7f62066e7000 rw-p 00004000 08:06 2626799                    /lib64/libattr.so.1.1.0
7f62066e7000-7f62066fb000 r-xp 00000000 08:06 1056008                    /usr/lib64/libelf-0.153.so
7f62066fb000-7f62068fa000 ---p 00014000 08:06 1056008                    /usr/lib64/libelf-0.153.so
7f62068fa000-7f62068fb000 r--p 00013000 08:06 1056008                    /usr/lib64/libelf-0.153.so
7f62068fb000-7f62068fc000 rw-p 00014000 08:06 1056008                    /usr/lib64/libelf-0.153.so
7f62068fc000-7f620690a000 r-xp 00000000 08:06 1056027                    /usr/lib64/libbz2.so.1.0.6
7f620690a000-7f6206b09000 ---p 0000e000 08:06 1056027                    /usr/lib64/libbz2.so.1.0.6
7f6206b09000-7f6206b0a000 r--p 0000d000 08:06 1056027                    /usr/lib64/libbz2.so.1.0.6
7f6206b0a000-7f6206b0b000 rw-p 0000e000 08:06 1056027                    /usr/lib64/libbz2.so.1.0.6
7f6206b0b000-7f6206b39000 r-xp 00000000 08:06 1056140                    /usr/lib64/liblua.so.5.1
7f6206b39000-7f6206d38000 ---p 0002e000 08:06 1056140                    /usr/lib64/liblua.so.5.1
7f6206d38000-7f6206d3a000 r--p 0002d000 08:06 1056140                    /usr/lib64/liblua.so.5.1
7f6206d3a000-7f6206d3b000 rw-p 0002f000 08:06 1056140                    /usr/lib64/liblua.so.5.1
7f6206d3b000-7f6206d43000 r-xp 00000000 08:06 2626769                    /lib64/libacl.so.1.1.0
7f6206d43000-7f6206f42000 ---p 00008000 08:06 2626769                    /lib64/libacl.so.1.1.0
7f6206f42000-7f6206f43000 r--p 00007000 08:06 2626769                    /lib64/libacl.so.1.1.0
7f6206f43000-7f6206f44000 rw-p 00008000 08:06 2626769                    /lib64/libacl.so.1.1.0
7f6206f44000-7f6206f48000 r-xp 00000000 08:06 2626797                    /lib64/libcap.so.2.22
7f6206f48000-7f6207147000 ---p 00004000 08:06 2626797                    /lib64/libcap.so.2.22
7f6207147000-7f6207148000 r--p 00003000 08:06 2626797                    /lib64/libcap.so.2.22
7f6207148000-7f6207149000 rw-p 00004000 08:06 2626797                    /lib64/libcap.so.2.22
7f6207149000-7f6207165000 r-xp 00000000 08:06 2626787                    /lib64/libselinux.so.1
7f6207165000-7f6207364000 ---p 0001c000 08:06 2626787                    /lib64/libselinux.so.1
7f6207364000-7f6207365000 r--p 0001b000 08:06 2626787                    /lib64/libselinux.so.1
7f6207365000-7f6207366000 rw-p 0001c000 08:06 2626787                    /lib64/libselinux.so.1
7f6207366000-7f6207367000 rw-p 00000000 00:00 0 
7f6207367000-7f6207372000 r-xp 00000000 08:06 1056012                    /usr/lib64/libpopt.so.0.0.0
7f6207372000-7f6207571000 ---p 0000b000 08:06 1056012                    /usr/lib64/libpopt.so.0.0.0
7f6207571000-7f6207572000 r--p 0000a000 08:06 1056012                    /usr/lib64/libpopt.so.0.0.0
7f6207572000-7f6207573000 rw-p 0000b000 08:06 1056012                    /usr/lib64/libpopt.so.0.0.0
7f6207573000-7f62075cc000 r-xp 00000000 08:06 1056011                    /usr/lib64/libpcre.so.1.0.0
7f62075cc000-7f62077cb000 ---p 00059000 08:06 1056011                    /usr/lib64/libpcre.so.1.0.0
7f62077cb000-7f62077cc000 r--p 00058000 08:06 1056011                    /usr/lib64/libpcre.so.1.0.0
7f62077cc000-7f62077cd000 rw-p 00059000 08:06 1056011                    /usr/lib64/libpcre.so.1.0.0
7f62077cd000-7f62077d4000 r-xp 00000000 08:06 1056031                    /usr/lib64/libffi.so.4.0.1
7f62077d4000-7f62079d3000 ---p 00007000 08:06 1056031                    /usr/lib64/libffi.so.4.0.1
7f62079d3000-7f62079d4000 r--p 00006000 08:06 1056031                    /usr/lib64/libffi.so.4.0.1
7f62079d4000-7f62079d5000 rw-p 00007000 08:06 1056031                    /usr/lib64/libffi.so.4.0.1
7f62079d5000-7f62079d8000 r-xp 00000000 08:06 1051790                    /usr/lib64/libgmodule-2.0.so.0.3200.4
7f62079d8000-7f6207bd7000 ---p 00003000 08:06 1051790                    /usr/lib64/libgmodule-2.0.so.0.3200.4
7f6207bd7000-7f6207bd8000 r--p 00002000 08:06 1051790                    /usr/lib64/libgmodule-2.0.so.0.3200.4
7f6207bd8000-7f6207bd9000 rw-p 00003000 08:06 1051790                    /usr/lib64/libgmodule-2.0.so.0.3200.4
7f6207bd9000-7f6207d50000 r-xp 00000000 08:06 1056050                    /usr/lib64/libdb-4.8.so
7f6207d50000-7f6207f50000 ---p 00177000 08:06 1056050                    /usr/lib64/libdb-4.8.so
7f6207f50000-7f6207f52000 r--p 00177000 08:06 1056050                    /usr/lib64/libdb-4.8.so
7f6207f52000-7f6207f55000 rw-p 00179000 08:06 1056050                    /usr/lib64/libdb-4.8.so
7f6207f55000-7f6207fb3000 r-xp 00000000 08:06 2626768                    /lib64/libssl.so.1.0.0
7f6207fb3000-7f62081b2000 ---p 0005e000 08:06 2626768                    /lib64/libssl.so.1.0.0
7f62081b2000-7f62081b6000 r--p 0005d000 08:06 2626768                    /lib64/libssl.so.1.0.0
7f62081b6000-7f62081bc000 rw-p 00061000 08:06 2626768                    /lib64/libssl.so.1.0.0
7f62081bc000-7f62081bd000 rw-p 00000000 00:00 0 
7f62081bd000-7f62081c4000 r-xp 00000000 08:06 2626660                    /lib64/librt-2.15.so
7f62081c4000-7f62083c3000 ---p 00007000 08:06 2626660                    /lib64/librt-2.15.so
7f62083c3000-7f62083c4000 r--p 00006000 08:06 2626660                    /lib64/librt-2.15.so
7f62083c4000-7f62083c5000 rw-p 00007000 08:06 2626660                    /lib64/librt-2.15.so
7f62083c5000-7f62083c6000 r-xp 00000000 08:06 1057546                    /usr/lib64/libgthread-2.0.so.0.3200.4
7f62083c6000-7f62085c5000 ---p 00001000 08:06 1057546                    /usr/lib64/libgthread-2.0.so.0.3200.4
7f62085c5000-7f62085c6000 r--p 00000000 08:06 1057546                    /usr/lib64/libgthread-2.0.so.0.3200.4
7f62085c6000-7f62085c7000 rw-p 00001000 08:06 1057546                    /usr/lib64/libgthread-2.0.so.0.3200.4
7f62085c7000-7f6208762000 r-xp 00000000 08:06 2626788                    /lib64/libc-2.15.so
7f6208762000-7f6208962000 ---p 0019b000 08:06 2626788                    /lib64/libc-2.15.so
7f6208962000-7f6208966000 r--p 0019b000 08:06 2626788                    /lib64/libc-2.15.so
7f6208966000-7f6208968000 rw-p 0019f000 08:06 2626788                    /lib64/libc-2.15.so
7f6208968000-7f620896c000 rw-p 00000000 00:00 0 
7f620896c000-7f6208981000 r-xp 00000000 08:06 2626663                    /lib64/libgcc_s.so.1
7f6208981000-7f6208b80000 ---p 00015000 08:06 2626663                    /lib64/libgcc_s.so.1
7f6208b80000-7f6208b81000 r--p 00014000 08:06 2626663                    /lib64/libgcc_s.so.1
7f6208b81000-7f6208b82000 rw-p 00015000 08:06 2626663                    /lib64/libgcc_s.so.1
7f6208b82000-7f6208c77000 r-xp 00000000 08:06 2626661                    /lib64/libm-2.15.so
7f6208c77000-7f6208e77000 ---p 000f5000 08:06 2626661                    /lib64/libm-2.15.so
7f6208e77000-7f6208e78000 r--p 000f5000 08:06 2626661                    /lib64/libm-2.15.so
7f6208e78000-7f6208e79000 rw-p 000f6000 08:06 2626661                    /lib64/libm-2.15.so
7f6208e79000-7f6208f61000 r-xp 00000000 08:06 1054136                    /usr/lib64/libstdc++.so.6.0.17
7f6208f61000-7f6209161000 ---p 000e8000 08:06 1054136                    /usr/lib64/libstdc++.so.6.0.17
7f6209161000-7f6209169000 r--p 000e8000 08:06 1054136                    /usr/lib64/libstdc++.so.6.0.17
7f6209169000-7f620916b000 rw-p 000f0000 08:06 1054136                    /usr/lib64/libstdc++.so.6.0.17
7f620916b000-7f6209180000 rw-p 00000000 00:00 0 
7f6209180000-7f62091da000 r-xp 00000000 08:06 1051937                    /usr/lib64/liblog4cplus-1.0.so.4.0.0
7f62091da000-7f62093d9000 ---p 0005a000 08:06 1051937                    /usr/lib64/liblog4cplus-1.0.so.4.0.0
7f62093d9000-7f62093dd000 r--p 00059000 08:06 1051937                    /usr/lib64/liblog4cplus-1.0.so.4.0.0
7f62093dd000-7f62093de000 rw-p 0005d000 08:06 1051937                    /usr/lib64/liblog4cplus-1.0.so.4.0.0
7f62093de000-7f62093df000 rw-p 00000000 00:00 0 
7f62093df000-7f62093f6000 r-xp 00000000 08:06 2626786                    /lib64/libpthread-2.15.so
7f62093f6000-7f62095f5000 ---p 00017000 08:06 2626786                    /lib64/libpthread-2.15.so
7f62095f5000-7f62095f6000 r--p 00016000 08:06 2626786                    /lib64/libpthread-2.15.so
7f62095f6000-7f62095f7000 rw-p 00017000 08:06 2626786                    /lib64/libpthread-2.15.so
7f62095f7000-7f62095fb000 rw-p 00000000 00:00 0 
7f62095fb000-7f6209607000 r-xp 00000000 08:06 2626795                    /lib64/libcrypt-2.15.so
7f6209607000-7f6209806000 ---p 0000c000 08:06 2626795                    /lib64/libcrypt-2.15.so
7f6209806000-7f6209807000 r--p 0000b000 08:06 2626795                    /lib64/libcrypt-2.15.so
7f6209807000-7f6209808000 rw-p 0000c000 08:06 2626795                    /lib64/libcrypt-2.15.so
7f6209808000-7f6209836000 rw-p 00000000 00:00 0 
7f6209836000-7f6209839000 r-xp 00000000 08:06 2626778                    /lib64/libdl-2.15.so
7f6209839000-7f6209a38000 ---p 00003000 08:06 2626778                    /lib64/libdl-2.15.so
7f6209a38000-7f6209a39000 r--p 00002000 08:06 2626778                    /lib64/libdl-2.15.so
7f6209a39000-7f6209a3a000 rw-p 00003000 08:06 2626778                    /lib64/libdl-2.15.so
7f6209a3a000-7f6209bbc000 r-xp 00000000 08:06 1317582                    /usr/lib/perl5/5.16.0/x86_64-linux-thread-multi/CORE/libperl.so
7f6209bbc000-7f6209dbc000 ---p 00182000 08:06 1317582                    /usr/lib/perl5/5.16.0/x86_64-linux-thread-multi/CORE/libperl.so
7f6209dbc000-7f6209dc0000 r--p 00182000 08:06 1317582                    /usr/lib/perl5/5.16.0/x86_64-linux-thread-multi/CORE/libperl.so
7f6209dc0000-7f6209dc6000 rw-p 00186000 08:06 1317582                    /usr/lib/perl5/5.16.0/x86_64-linux-thread-multi/CORE/libperl.so
7f6209dc6000-7f6209dc7000 rw-p 00000000 00:00 0 
7f6209dc7000-7f6209dd0000 r-xp 00000000 08:06 2626805                    /lib64/libwrap.so.0.7.6
7f6209dd0000-7f6209fcf000 ---p 00009000 08:06 2626805                    /lib64/libwrap.so.0.7.6
7f6209fcf000-7f6209fd0000 r--p 00008000 08:06 2626805                    /lib64/libwrap.so.0.7.6
7f6209fd0000-7f6209fd1000 rw-p 00009000 08:06 2626805                    /lib64/libwrap.so.0.7.6
7f6209fd1000-7f6209fd2000 rw-p 00000000 00:00 0 
7f6209fd2000-7f620a17b000 r-xp 00000000 08:06 2626777                    /lib64/libcrypto.so.1.0.0
7f620a17b000-7f620a37b000 ---p 001a9000 08:06 2626777                    /lib64/libcrypto.so.1.0.0
7f620a37b000-7f620a396000 r--p 001a9000 08:06 2626777                    /lib64/libcrypto.so.1.0.0
7f620a396000-7f620a3a1000 rw-p 001c4000 08:06 2626777                    /lib64/libcrypto.so.1.0.0
7f620a3a1000-7f620a3a5000 rw-p 00000000 00:00 0 
7f620a3a5000-7f620a44d000 r-xp 00000000 08:06 1058017                    /usr/lib64/libnetsnmp.so.30.0.1
7f620a44d000-7f620a64d000 ---p 000a8000 08:06 1058017                    /usr/lib64/libnetsnmp.so.30.0.1
7f620a64d000-7f620a64e000 r--p 000a8000 08:06 1058017                    /usr/lib64/libnetsnmp.so.30.0.1
7f620a64e000-7f620a652000 rw-p 000a9000 08:06 1058017                    /usr/lib64/libnetsnmp.so.30.0.1
7f620a652000-7f620a687000 rw-p 00000000 00:00 0 
7f620a687000-7f620a6f2000 r-xp 00000000 08:06 1058019                    /usr/lib64/libnetsnmpagent.so.30.0.1
7f620a6f2000-7f620a8f1000 ---p 0006b000 08:06 1058019                    /usr/lib64/libnetsnmpagent.so.30.0.1
7f620a8f1000-7f620a8f2000 r--p 0006a000 08:06 1058019                    /usr/lib64/libnetsnmpagent.so.30.0.1
7f620a8f2000-7f620a8f4000 rw-p 0006b000 08:06 1058019                    /usr/lib64/libnetsnmpagent.so.30.0.1
7f620a8f4000-7f620a8f5000 rw-p 00000000 00:00 0 
7f620a8f5000-7f620a93e000 r-xp 00000000 08:06 1056155                    /usr/lib64/librpmio.so.2.0.1
7f620a93e000-7f620ab3e000 ---p 00049000 08:06 1056155                    /usr/lib64/librpmio.so.2.0.1
7f620ab3e000-7f620ab40000 r--p 00049000 08:06 1056155                    /usr/lib64/librpmio.so.2.0.1
7f620ab40000-7f620ab44000 rw-p 0004b000 08:06 1056155                    /usr/lib64/librpmio.so.2.0.1
7f620ab44000-7f620ab47000 rw-p 00000000 00:00 0 
7f620ab47000-7f620ad0f000 r-xp 00000000 08:06 1056077                    /usr/lib64/librpm.so.2.0.2
7f620ad0f000-7f620af0e000 ---p 001c8000 08:06 1056077                    /usr/lib64/librpm.so.2.0.2
7f620af0e000-7f620af13000 r--p 001c7000 08:06 1056077                    /usr/lib64/librpm.so.2.0.2
7f620af13000-7f620af16000 rw-p 001cc000 08:06 1056077                    /usr/lib64/librpm.so.2.0.2
7f620af16000-7f620af24000 r-xp 00000000 08:06 1057682                    /usr/lib64/libsensors.so.4.3.2
7f620af24000-7f620b123000 ---p 0000e000 08:06 1057682                    /usr/lib64/libsensors.so.4.3.2
7f620b123000-7f620b124000 r--p 0000d000 08:06 1057682                    /usr/lib64/libsensors.so.4.3.2
7f620b124000-7f620b125000 rw-p 0000e000 08:06 1057682                    /usr/lib64/libsensors.so.4.3.2
7f620b125000-7f620b2a4000 r-xp 00000000 08:06 1058023                    /usr/lib64/libnetsnmpmibs.so.30.0.1
7f620b2a4000-7f620b4a3000 ---p 0017f000 08:06 1058023                    /usr/lib64/libnetsnmpmibs.so.30.0.1
7f620b4a3000-7f620b4a5000 r--p 0017e000 08:06 1058023                    /usr/lib64/libnetsnmpmibs.so.30.0.1
7f620b4a5000-7f620b4b0000 rw-p 00180000 08:06 1058023                    /usr/lib64/libnetsnmpmibs.so.30.0.1
7f620b4b0000-7f620b55a000 rw-p 00000000 00:00 0 
7f620b55a000-7f620b64f000 r-xp 00000000 08:06 1051645                    /usr/lib64/libglib-2.0.so.0.3200.4
7f620b64f000-7f620b84e000 ---p 000f5000 08:06 1051645                    /usr/lib64/libglib-2.0.so.0.3200.4
7f620b84e000-7f620b84f000 r--p 000f4000 08:06 1051645                    /usr/lib64/libglib-2.0.so.0.3200.4
7f620b84f000-7f620b850000 rw-p 000f5000 08:06 1051645                    /usr/lib64/libglib-2.0.so.0.3200.4
7f620b850000-7f620b851000 rw-p 00000000 00:00 0 
7f620b851000-7f620b856000 r-xp 00000000 08:06 1063070                    /usr/lib64/libsigc-2.0.so.0.0.0
7f620b856000-7f620ba55000 ---p 00005000 08:06 1063070                    /usr/lib64/libsigc-2.0.so.0.0.0
7f620ba55000-7f620ba56000 r--p 00004000 08:06 1063070                    /usr/lib64/libsigc-2.0.so.0.0.0
7f620ba56000-7f620ba57000 rw-p 00005000 08:06 1063070                    /usr/lib64/libsigc-2.0.so.0.0.0
7f620ba57000-7f620baa3000 r-xp 00000000 08:06 1051844                    /usr/lib64/libgobject-2.0.so.0.3200.4
7f620baa3000-7f620bca3000 ---p 0004c000 08:06 1051844                    /usr/lib64/libgobject-2.0.so.0.3200.4
7f620bca3000-7f620bca4000 r--p 0004c000 08:06 1051844                    /usr/lib64/libgobject-2.0.so.0.3200.4
7f620bca4000-7f620bca5000 rw-p 0004d000 08:06 1051844                    /usr/lib64/libgobject-2.0.so.0.3200.4
7f620bca5000-7f620bd11000 r-xp 00000000 08:06 1063080                    /usr/lib64/libglibmm-2.4.so.1.3.0
7f620bd11000-7f620bf10000 ---p 0006c000 08:06 1063080                    /usr/lib64/libglibmm-2.4.so.1.3.0Avbrutt (SIGABRT)


This post has been edited by DJViking: 21 November 2012 - 01:03 AM

Was This Post Helpful? 0
  • +
  • -

#21 DJViking  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 25
  • Joined: 07-November 12

Re: less-than operator overloader for a long array

Posted 21 November 2012 - 01:19 AM

In the context of this oid_wrapper. Any hints on how to get rid of the following warnings?

oid_wrapper.h:77:34: warning: type qualifiers ignored on function return type [-Wignored-qualifiers]
oid_wrapper.h: In member function ‘oid oid_wrapper::operator[](unsigned int)’:
oid_wrapper.h:106:13: warning: comparison between signed and unsigned integer expressions

Line 77:
const long getLastNumberInOid() const { return oid_value[oid_length - 1]; }



Line 105-107:
oid operator[](unsigned i) {
  return (i<oid_length) ? oid_value[i] : oid();
}



Net-SNMP uses size_t, which is an long unsigned int. I use a regular int for length in my oid_wrapper.
Perhaps if I use the same I could get rid if these warnings.

What is the difference between long unsigned int, unsigned long int and unsigned long?

Anyway: I changed length to type unsigned long and it got rid of the warning on line 106.

Was thinking perhaps using the typedef uint64_t was preferable.

This post has been edited by DJViking: 21 November 2012 - 01:28 AM

Was This Post Helpful? 0
  • +
  • -

#22 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5643
  • View blog
  • Posts: 12,359
  • Joined: 16-October 07

Re: less-than operator overloader for a long array

Posted 21 November 2012 - 08:25 AM

I got curious enough to take a good look at this. There were a huge amount of warnings about no "oid_wrapper(const oid_wrapper &)", which is a big issue. Also, in using snmp_duplicate_objid you're using malloc. But you also use new. This is very bad juju.


I did a quick clean up of this. Ran fine, no errors.

#include <iostream>
#include <map>
#include <ostream>
#include <sstream>
#include <stdexcept>
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>


class oid_wrapper {
public:
	oid_wrapper(const oid *, int);
	oid_wrapper(const oid *, int, int);
	oid_wrapper(const oid_wrapper &);
	oid_wrapper(const oid_wrapper &, int);
	~oid_wrapper();
	oid operator[](unsigned);
	int get_length() const;
	oid_wrapper& operator=(const oid_wrapper &);
	int compare(const oid_wrapper &) const;
	oid getLastNumberInOid() const;
	bool operator==(const oid_wrapper &) const;
	bool operator<(const oid_wrapper &) const;
	bool operator!=(const oid_wrapper &) const;
	bool operator>(const oid_wrapper &) const;
	bool operator<=(const oid_wrapper &) const;
	bool operator>=(const oid_wrapper &) const;
	void print(std::ostream &out) const;
private:
	oid *oid_value;
	int oid_length;
};

std::ostream& operator<<(std::ostream &, const oid_wrapper &);

using namespace std;


int main(int argc, char **argv) {

	cout << "Testing first set of OID" << endl;
	const oid oid1[] = { 1,3,6,1,4,1,40850,1,3 };
	const oid_wrapper parent1 (oid1, 9);
	const oid_wrapper parent1_child1 (parent1, 40);
	const oid_wrapper parent1_child2 (parent1, 41);
	const oid_wrapper parent1_child3 (parent1, 42);
	const oid_wrapper parent1_child4 (parent1, 43);

	map<oid_wrapper, string> test;
	test.insert(make_pair(parent1_child1, "parent1_child1"));
	test.insert(make_pair(parent1_child2, "parent1_child2"));
	test.insert(make_pair(parent1_child3, "parent1_child3"));
	test.insert(make_pair(parent1_child4, "parent1_child4"));
	if (test.size() != 4) { cout << "FAIL" << endl; }
	cout << "Number of OID in list: " << test.size() << endl;

	const oid_wrapper parent11 (oid1, 9);
	const oid_wrapper parent1_child11 (parent11, 40);
	try {
		string teststring = test.at(parent1_child11);
		cout << "Success" << endl;
	} catch (out_of_range& e) {
		cout << "Failure" << endl;
	}

	const oid_wrapper parent1_child12 (parent11, 41);
	try {
		string teststring = test.at(parent1_child12);
		cout << "Success" << endl;
	} catch (out_of_range& e) {
		cout << "Failure" << endl;
	}

	const oid_wrapper parent1_child13 (parent11, 42);
	try {
		string teststring = test.at(parent1_child13);
		cout << "Success" << endl;
	} catch (out_of_range& e) {
		cout << "Failure" << endl;
	}

	const oid_wrapper parent1_child14 (parent11, 43);
	try {
		string teststring = test.at(parent1_child14);
		cout << "Success" << endl;
	} catch (out_of_range& e) {
		cout << "Failure" << endl;
	}

	cout << "Testing second set of OID" << endl;
	const oid oid2[] = { 1,3,6,1,4,1,40850,2,1,9,1 };
	const oid_wrapper parent2 (oid2, 11);
	const oid_wrapper parent2_child1 (parent2, 1);
	const oid_wrapper parent2_child2 (parent2, 2);
	const oid_wrapper parent2_child3 (parent2, 3);
	const oid_wrapper parent2_child4 (parent2, 4);

	test.insert(make_pair(parent2_child1, "parent2_child1"));
	test.insert(make_pair(parent2_child2, "parent2_child2"));
	test.insert(make_pair(parent2_child3, "parent2_child3"));
	test.insert(make_pair(parent2_child4, "parent2_child4"));
	if (test.size() != 8) { cout << "FAIL" << endl; }
	cout << "Number of OID in list: " << test.size() << endl;

	const oid_wrapper parent21 (oid2, 11);
	const oid_wrapper parent1_child21 (parent21, 1);
	try {
		string teststring = test.at(parent1_child21);
		cout << "Success" << endl;
	} catch (out_of_range& e) {
		cout << "Failure" << endl;
	}

	const oid_wrapper parent1_child22 (parent21, 2);
	try {
		string teststring = test.at(parent1_child22);
		cout << "Success" << endl;
	} catch (out_of_range& e) {
		cout << "Failure" << endl;
	}

	const oid_wrapper parent1_child23 (parent21, 3);
	try {
		string teststring = test.at(parent1_child23);
		cout << "Success" << endl;
	} catch (out_of_range& e) {
		cout << "Failure" << endl;
	}

	const oid_wrapper parent1_child24 (parent21, 4);
	try {
		string teststring = test.at(parent1_child24);
		cout << "Success" << endl;
	} catch (out_of_range& e) {
		cout << "Failure" << endl;
	}

	//#################################################

	//Adding 100 OIDs
	for (int i = 0; i < 100; i++) {
		const oid newoid[] = { 1,3,6,1,4,1,40850,2,4,9,1 };
		const oid_wrapper wrapper(newoid, 11, i);
		test.insert(make_pair(wrapper, "wrapper"));
	}

	//Query for the 100 added OIDs
	int run1 = 0;
	for (int i = 0; i < 100; i++) {
		const oid newoid[] = { 1,3,6,1,4,1,40850,2,4,9,1 };
		const oid_wrapper wrapper(newoid, 11, i);

		std::map<oid_wrapper, string>::iterator iter = test.find(wrapper);
		if (iter != test.end()) {
			run1++;
		}
	}
	cout << "Run 1: " << run1 << endl;

	//#################################################

	//Adding 100 OIDs
	for (int i = 0; i < 100; i++) {
		const oid newoid[] = { 1,3,6,1,4,1,40850,1,4 };
		const oid_wrapper wrapper(newoid, 9, i);
		test.insert(make_pair(wrapper, "wrapper"));
	}

	//Query for the 100 added OIDs
	int run2 = 0;
	for (int i = 0; i < 100; i++) {
		const oid newoid[] = { 1,3,6,1,4,1,40850,1,4 };
		const oid_wrapper wrapper(newoid, 9, i);

		std::map<oid_wrapper, string>::iterator iter = test.find(wrapper);
		if (iter != test.end()) {
			run2++;
		}
	}
	cout << "Run 2: " << run2 << endl;

	//#################################################

	//Adding 100 OIDs
	for (int i = 0; i < 100; i++) {
		const oid newoid[] = { 1,3,6,1,4,1,40850,2 };
		const oid_wrapper wrapper(newoid, 8, i);
		test.insert(make_pair(wrapper, "wrapper"));
	}

	//Query for the 100 added OIDs
	int run3 = 0;
	for (int i = 0; i < 100; i++) {
		const oid newoid[] = { 1,3,6,1,4,1,40850,2 };
		const oid_wrapper wrapper(newoid, 8, i);

		std::map<oid_wrapper, string>::iterator iter = test.find(wrapper);
		if (iter != test.end()) {
			run3++;
		}
	}
	cout << "Run 3: " << run3 << endl;

	//#################################################

	//Adding 500 OIDs
	for (int i = 0; i < 100; i++) {
		const oid newoid[] = { 1,3,6,1,4,1,40850,2,2,5,1 };
		const oid_wrapper wrapper(newoid, 11, i);
		test.insert(make_pair(wrapper, "wrapper"));
	}

	//Query for the 500 added OIDs
	int run4 = 0;
	for (int i = 0; i < 100; i++) {
		const oid newoid[] = { 1,3,6,1,4,1,40850,2,2,5,1 };
		const oid_wrapper wrapper(newoid, 11, i);

		std::map<oid_wrapper, string>::iterator iter = test.find(wrapper);
		if (iter != test.end()) {
			run4++;
		}
	}
	cout << "Run 4: " << run4 << endl;

	//#################################################

	//Adding 500 OIDs
	for (int i = 0; i < 100; i++) {
		const oid newoid[] = { 1,3,6,1,4,1,40850,2,3,5,2 };
		const oid_wrapper wrapper(newoid, 11, i);
		test.insert(make_pair(wrapper, "wrapper"));
	}

	//Query for the 500 added OIDs
	int run5 = 0;
	for (int i = 0; i < 100; i++) {
		const oid newoid[] = { 1,3,6,1,4,1,40850,2,3,5,2 };
		const oid_wrapper wrapper(newoid, 11, i);

		std::map<oid_wrapper, string>::iterator iter = test.find(wrapper);
		if (iter != test.end()) {
			run5++;
		}
	}
	cout << "Run 5: " << run5 << endl;

	//#################################################

	//Adding 500 OIDs
	for (int i = 0; i < 100; i++) {
		const oid newoid[] = { 1,3,6,1,4,1,40850,2,2,5,2 };
		const oid_wrapper wrapper(newoid, 10, i);
		test.insert(make_pair(wrapper, "wrapper"));
	}

	//Query for the 500 added OIDs
	int run6 = 0;
	for (int i = 0; i < 100; i++) {
		const oid newoid[] = { 1,3,6,1,4,1,40850,2,2,5,2 };
		const oid_wrapper wrapper(newoid, 10, i);

		std::map<oid_wrapper, string>::iterator iter = test.find(wrapper);
		if (iter != test.end()) {
			run6++;
		}
	}
	cout << "Run 6: " << run6 << endl;


	//#################################################

	//Adding 500 OIDs
	for (int i = 0; i < 100; i++) {
		const oid newoid[] = { 1,3,6,1,4,1,40850,2,5,2,3,5 };
		const oid_wrapper wrapper(newoid, 12, i);
		test.insert(make_pair(wrapper, "wrapper"));
	}

	//Query for the 500 added OIDs
	int run7 = 0;
	for (int i = 0; i < 100; i++) {
		const oid newoid[] = { 1,3,6,1,4,1,40850,2,5,2,3,5 };
		const oid_wrapper wrapper(newoid, 12, i);

		std::map<oid_wrapper, string>::iterator iter = test.find(wrapper);
		if (iter != test.end()) {
			run7++;
		}
	}
	cout << "Run 7: " << run7 << endl;

	cout << "Total in map " << test.size() << endl;
	return 0;
}


static oid *createStorage(int size) { return new oid[size]; }

static oid *dupStorage(oid *dst, const oid *src, int size) {
	for(int i=0; i<size; i++) { dst[i] = src[i]; }
	return dst;
}

static void freeStorage(oid *&s, int &size) {
	if (size!=0) {
		delete [] s;
		size = 0;
		s = NULL;
	}
}

oid_wrapper::oid_wrapper(const oid *value, int len) 
	: oid_value(dupStorage(createStorage(len), value, len)), oid_length(len) 
{
}

oid_wrapper::oid_wrapper(const oid *value, int len, int assigned_value) 
	: oid_value(dupStorage(createStorage(len+1), value, len)), oid_length(len+1)
{
	oid_value[oid_length-1] = assigned_value;
}

oid_wrapper::oid_wrapper(const oid_wrapper &other, int assigned_value) 
	: oid_value(dupStorage(createStorage(other.oid_length+1), other.oid_value, other.oid_length)), 
		oid_length(other.oid_length+1)
{
	oid_value[oid_length-1] = assigned_value;
}

oid_wrapper::oid_wrapper(const oid_wrapper &other) 
	: oid_value(dupStorage(createStorage(other.oid_length), other.oid_value, other.oid_length)), 
		oid_length(other.oid_length) 
{
}


oid_wrapper::~oid_wrapper() { freeStorage(oid_value, oid_length); }

oid oid_wrapper::operator[](unsigned i) { return (i<oid_length) ? oid_value[i] : oid(); }

int oid_wrapper::get_length() const { return oid_length; }

oid_wrapper& oid_wrapper::operator=(const oid_wrapper & other) {
	if (other.oid_length!=oid_length) {
		freeStorage(oid_value, oid_length);
		oid_value = createStorage(other.oid_length);
		oid_length = other.oid_length;
	}
	dupStorage(oid_value, other.oid_value, oid_length);
	return *this;
}

int oid_wrapper::compare(const oid_wrapper& rhs) const {
	return snmp_oid_compare (oid_value, oid_length, rhs.oid_value, rhs.oid_length);
}

oid oid_wrapper::getLastNumberInOid() const { return oid_value[oid_length - 1]; }

bool oid_wrapper::operator==(const oid_wrapper& rhs) const { return compare(rhs)==0; }
bool oid_wrapper::operator<(const oid_wrapper& rhs) const { return compare(rhs)<0; }
bool oid_wrapper::operator!=(const oid_wrapper& rhs) const { return compare(rhs)!=0; }
bool oid_wrapper::operator>(const oid_wrapper& rhs) const { return compare(rhs)>0; }
bool oid_wrapper::operator<=(const oid_wrapper& rhs) const { return compare(rhs)<=0; }
bool oid_wrapper::operator>=(const oid_wrapper& rhs) const { return compare(rhs)>=0; }

void oid_wrapper::print(std::ostream &out) const {
	for(int i = 0; i < oid_length; i++) {
		if (i != 0) { out << "."; }
		out << oid_value[i];
	}

}


Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2