Skip to content

Instantly share code, notes, and snippets.

@Elv13
Created March 10, 2014 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Elv13/9467161 to your computer and use it in GitHub Desktop.
Save Elv13/9467161 to your computer and use it in GitHub Desktop.
class B;
class A {
friend class B;
public:
const QByteArray content() const {
return QByteArray::fromRawData(content,size);
}
private:
A(int* count_ref,const char* c, const int s, const int k, B* m):manager(m),size(s),content(c),key(k) {
count = count_ref;
(*count)++;
}
A(const A& copy);
~A() {
(*count)++;
if ((*count) >= 0)
manager->free(key);
}
int* count;
B* manager;
const int size;
const char* content;
const int key;
};
class B {
frient class A;
A get(QByteArray b) {
//create an "A"
}
private:
void free(int key) {
//free the string
}
struct MyInternalStruct {
char* content;
int size;
int key;
};
QHash<int key,MyInternalStruct*> m_hCache;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment