I have googled around but I've found only an old and not Qt APi QMemoryFile Class.
Thanks
Marco
I have googled around but I've found only an old and not Qt APi QMemoryFile Class.
Thanks
Marco
Use "mmap()". Memory mapping is not know in Windows world, so there is no point putting it in Qt.
AFAIK, D-Bus is not available in Windows and Qt seems to have it ?
We can't solve problems by using the same kind of thinking we used when we created them
Ok, specially for you:
Qt Code:
#include <sys/mman.h> QwwMemoryMapper { public: enum Protection { None, Readable, Writable, Executable }; int protfl=PROT_NONE; if(prot & Readable) protfl|=PROT_READ; if(prot & Writable) protfl|=PROT_WRITE; if(prot & Executable) protfl|=PROT_EXEC; _pointer = mmap(0, length, protfl, shared ? MAP_SHARED : MAP_PRIVATE, f.handle(), offset); _length = length; } ~QwwMemoryMapper(){ munmap(_pointer, _length); } void *pointer() const { return _pointer; } int mappedLength() const { return _length; } private: void *_pointer; int _length; };To copy to clipboard, switch view to plain text mode
As for DBUS:
1. It is being implemented on Windows
2. It is more than two functions (in contrast to mmap()) so it does make sense to map it to Qt API.
Waw !!, Obvously did not know that. thank uAs for DBUS:
1. It is being implemented on Windows
I agree, did not know what memory mapped file just was2. It is more than two functions (in contrast to mmap()) so it does make sense to map it to Qt API. Today 16:10
I read somewhere IIRC ( int C++ Coding standard ) , that it is not recommended to use an underscore as a start character ? And the author has not given reason for why it should not be used.Qt Code:
void *_pointer; int _length;To copy to clipboard, switch view to plain text mode
Just google and found this http://www.doc.ic.ac.uk/lab/cplus/c++.rules/chap5.html
http://www.cs.cmu.edu/afs/cs.cmu.edu...tyleguide.html
http://www-hera-b.desy.de/subgroup/s...dingrules.html
We can't solve problems by using the same kind of thinking we used when we created them
Because this might cause name clashes. But it doesn't apply when used in classes because classes provide own namespaces for internal fields, so it won't cause trouble.
And sorry, but academic rules written by teachers for their students somehow doesn't seem to bother me that much
It's like with the Pirate Codebook - it's more a list of guidelines than actual rules.
It isn't recommended, because identifiers that start with underscore and capital letter or another underscore are reserved for the compiler. This is somewhat similar to a rule like "don't use pointers, because you might get a memory leak" --- it's just too defensive.
Well this is the reply I got from Marsha Cline.
Glad the C++ FAQ has helped.
According to the standard, the namespace reserved by the compiler includes identifiers that start with an underscore followed immediately by a capital letter as well as identifiers that contain a double-underscore anywhere within the identifier – beginning, ending, in the middle, anywhere. That means names like __foo or foo__bar or _Foo are bad, but _foo is okay *if* the compiler had no accidental names starting with an underscore followed immediately by a lower-case letter. However I personally avoid leading underscores since I was burned once by a compiler that had erroneously stolen one of those identifiers, so instead I use trailing underscores to indicate member variables.
Marshall
We can't solve problems by using the same kind of thinking we used when we created them
The class name is part of the identifier, so in reality those identifiers start with "QwwMemoryMapper". But if you really want to keep then conversation going, then simply run sed -e "s/_/m_/g" on the source code and let's forget about the problem.
Unless, of course, something reserves it via a #define.
I prefer length_, since if you've got a spiffy type-ahead UI, you won't have everything starting with the same character.
I prefer _length to length_ because all the following sucks
length_->something
length_.something
length_++
length_[n]
length_(x)
x = length_;
and probably also something more that I don't remember now.
wysota
can you please give exmple how to use the QwwMemoryMapper class you wrote in here
Bookmarks