Abandoned writings

I was looking over the draft posts I have in my blog system, and I came across this beauty from last July. I don't even remember writing it, but I wished I would have finished it. It really seemed like I was onto something, like a great mystery of the universe on the verge of being revealed.

Oh well, here it is in its unfinished glory:

A Buffer Too Far

Ok, so I'm writing CouchDb in C++, and lately I'm starting to question that decision. The reason I'm writing it in C++ is because it makes it easier to embed and integrate with other products/languages/devices.

Ok, so I'm trying to use the STL more and invent my own code less. And I'm realizing its fucked. Or maybe I'm just an idiot. Nah, I'm pretty sure it's fucked.

Ok, so I have type structure like this:
vector< pair<StreamPointer, vector<BYTE> > > x;

Now, for those that can't read this monstrosity above (which I really wrote in CouchDb), it says:

Make a thing called x. That thing will be a vector (a resizable array) that holds pair values, and those pair values each will hold a StreamPointer and also a vector that hold bytes.

For those who are still with me, that's ugly.

So I have an alternative, I can typedef stuff to make the declaration cleaner:

typedef pair<StreamPointer, vector<BYTE> > StreamPointerBufferPair;
vector<StreamPointerBufferPair> x;

Now, the line above says:
Make a thing called x. That thing will be a vector (a resizable array) that holds StreamPointerBufferPar.

StreamPointerBufferPair is a bit, eh, um....wordy. I guess. It's just that it's long. Buts it's sort of clear what it is, except for the Buffer part, which is a actually a vector<BYTE>, I'm not sure how to describe it clearly otherwise. So maybe this is cleaner:

typedef vector<BYTE> Buffer;
typedef pair<StreamPointer, Buffer > StreamPointerBufferPair;
vector<StreamPointerBufferPair> x;

Ok, that's maybe a little better. So lets continue coding. The developer now wants to use


Apparently I was clubbed in the head by an intruder at the end there, and I managed to get out "grdz" before the intruder saved my work and tucked me into bed. He's thoughtful that way.

Posted December 31, 2005 2:00 PM