473,756 Members | 4,046 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

copy content of vector<BYTE> to BYTE*

Hi,

I have replaced my BYTE* by a vector<BYTE> and before I used to do :

void CCardRecord::Ge tRecData(int nOffset, int nDataSize, CString& csValue)
{
BYTE *pTmp = NULL;
pTmp = new BYTE[nDataSize + 1];
memset(pTmp, 0, nDataSize + 1);
//memcpy(pTmp, &m_pData[ nOffset ], nDataSize);
csValue = pTmp;
}

But now m_pData is a vector.
Jul 22 '05
16 9223

"White Wolf" <wo***@freemail .hu> wrote in message
news:cs******** **@phys-news1.kolumbus. fi...
gMorphus wrote:
[<<<snip] Now I guess all we need is to remember that Michael Jackson, who is not
in jail and not on bail.
Umm... what? Can you diagram that sentence? Or at least complete it? :-)
Or Knuth.
Ditto.
They have placed the root of evil to a very different place than the
current US government.
Tread lightly there, friend. We may not all like Bush/Cheney, but it's
still OUR government.

Sorry for the (kinda) outburts, nothing personal. I just wanted to point
out that guesswork is evil. Especially if people believe it.


Apology accepted, I guess. ;-)

-Howard
"Life is like a donut. With sprinkles. Mmmm...sprinkle s!"
Jul 22 '05 #11
gMorphus wrote:
Ok, after a little investigation I have realized that my solution is
not good.
That operator overlaoding wouldn't work for vector because the type
will be a "const unsigned char *" - which you cannot overload.

Moreover, I think the copy function _cannot_ be overloaded. The reason
for is the same - the vector iterator is simply a pointer, which you
cannot be overloaded or specialised.

Am I right?


No, you aren't.

1.) Copy can be overloaded, since it is *noty* an operator function. Now it
may be a very bad idea to overload it, but it can be done. Although it
cannot (eh, must not) be overloaded as std::copy.

2.) The vector iterator *may* be a pointer. In more and more Standard
Library implementations it is more and more frequently not apointer. And
of course any function can be overloaded and any template can be specialized
for pointers. Operators cannot be. It may be a very bad idea to do so with
"well known functions", but it can be done:

void foo(int);
void foo(char const *);
void foo(std::vector <char>::const_i terator);

Of course, if your iterator implementation happens to use typedefs to create
a type alias const_iterator for char const *, the above code will not
compile.

You do have good point, but your wording uses too strict statements:

"That operator overlaoding wouldn't work for vector because the type
/may/ be a "const unsigned char *" - /and/ you cannot overload /an operator
for that type/."

--
WW aka Attila
:::
SUSHIDO: The way of the Tuna.
Jul 22 '05 #12
White Wolf wrote:
[...]
1.) Copy can be overloaded, since it is *noty* [...]


I think it's spelled *naughty*

:-) Sorry, couldn't resist...
Jul 22 '05 #13
Howard wrote:
"White Wolf" <wo***@freemail .hu> wrote in message
news:cs******** **@phys-news1.kolumbus. fi...
gMorphus wrote:
[<<<snip]

Now I guess all we need is to remember that Michael Jackson, who is not
in jail and not on bail.


Umm... what? Can you diagram that sentence? Or at least complete it?
:-)


Read Herb Sutter more often. ;-) Did you at least make an attempt to ask
Google about Michel Jackson and optimization? Hints:

"Principles of Program Design" by M.A. Jackson, Associated Press 1975
ISBN 0 12 379050 6

Michael Jackson, rules of optimization:

Rule 1. Don't do it.
Rule 2. (for experts only) Don't do it yet.
Or Knuth.


Ditto.


Not knowing Knuth as a programmer is excuseable. But telling it in public
is not wise. First hit on Google:

http://www-cs-faculty.stanford.edu/~knuth/

I feel like the father, whose 25 years old sun calls out from the toilet: I
have finished, you can come!
They have placed the root of evil to a very different place than the
current US government.


Tread lightly there, friend. We may not all like Bush/Cheney, but it's
still OUR government.


Yours my friend. Not mine. Mine is worse than your, but at least has no
nucular weapons, or any other weapons of mass destruction, with
pronounciation errors or without.
Sorry for the (kinda) outburts, nothing personal. I just wanted to
point out that guesswork is evil. Especially if people believe it.


Apology accepted, I guess. ;-)


Understanding what was said may have been more benefitial.

--
WW aka Attila
:::
Nothing makes your clothes go out of fashion faster than getting a raise.
Jul 22 '05 #14
Victor Bazarov wrote:
White Wolf wrote:
[...]
1.) Copy can be overloaded, since it is *noty* [...]


I think it's spelled *naughty*

:-) Sorry, couldn't resist...


Ohm I couldn't resist. (Bad joke, but that's all I can do today.)

--
WW aka Attila
:::
Birthdays are good for you. Statistics show that the people who have the
most live the longest.
Jul 22 '05 #15

"White Wolf" <wo***@freemail .hu> wrote in message
news:cs******** **@phys-news1.kolumbus. fi...
Howard wrote:
"White Wolf" <wo***@freemail .hu> wrote in message
news:cs******** **@phys-news1.kolumbus. fi...
gMorphus wrote:
[<<<snip]
Now I guess all we need is to remember that Michael Jackson, who is not
in jail and not on bail.


Umm... what? Can you diagram that sentence? Or at least complete it?
:-)


Read Herb Sutter more often. ;-) Did you at least make an attempt to ask
Google about Michel Jackson and optimization? Hints:


Sorry. I thought "remember that..." meant something like "remember that you
need to lift the toilet seat...". I suppose you meant it like "remember
that Michael Jackson guy?" As I read it, it wasn't a complete sentence.
"Principles of Program Design" by M.A. Jackson, Associated Press 1975
ISBN 0 12 379050 6

Michael Jackson, rules of optimization:

Rule 1. Don't do it.
Rule 2. (for experts only) Don't do it yet.
Or Knuth.
Ditto.


Not knowing Knuth as a programmer is excuseable. But telling it in public
is not wise. First hit on Google:


Again, I was commenting (joking) about your lack of complete sentences. "Or
Knuth" lacks something as sentences go.
http://www-cs-faculty.stanford.edu/~knuth/

I feel like the father, whose 25 years old sun calls out from the toilet:
I have finished, you can come!
They have placed the root of evil to a very different place than the
current US government.
Tread lightly there, friend. We may not all like Bush/Cheney, but it's
still OUR government.


Yours my friend. Not mine. Mine is worse than your, but at least has no
nucular weapons, or any other weapons of mass destruction, with
pronounciation errors or without.
Sorry for the (kinda) outburts, nothing personal. I just wanted to
point out that guesswork is evil. Especially if people believe it.


Apology accepted, I guess. ;-)


Understanding what was said may have been more benefitial.


(I thought the smiley faces were a clue I was just joking?)

--
WW aka Attila
:::
Nothing makes your clothes go out of fashion faster than getting a raise.

Jul 22 '05 #16
Howard wrote:
[SNIP]
Read Herb Sutter more often. ;-) Did you at least make an attempt to
ask Google about Michel Jackson and optimization? Hints:
Sorry. I thought "remember that..." meant something like "remember that
you need to lift the toilet seat...". I suppose you meant it like
"remember that Michael Jackson guy?" As I read it, it wasn't a complete
sentence.


Yeah. It also happens to me. It can be quite fun when you stare at your
own slides on a course. That is when I take a note to simplify the
language. :-)

[SNIP] Again, I was commenting (joking) about your lack of complete sentences.
"Or Knuth" lacks something as sentences go.


And deliberately so. ;-)

[SNIP]
Apology accepted, I guess. ;-)


Understanding what was said may have been more benefitial.


(I thought the smiley faces were a clue I was just joking?)


You were joking and I was serious about the part that please please don't do
guesswork.

--
WW aka Attila
:::
Sorry - yesterday was the deadline for all complaints.
Jul 22 '05 #17

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
4144
by: klaas | last post by:
the following code gives rise to the beneath error message, only when a matrix object is instantiated as matrix<bool>, not with matrix<float>: /*returns a reference to the object at position (Row,Col) in matrix*/ template <class num_type,template <class T> class functor> num_type & matrix<num_type,functor >::operator()(const int Row,const int Col) {if (Row<rows && Col<cols) {vector<num_type> & x=matrix_core; //num_type & y=x;<-is also...
3
3463
by: Alexandros | last post by:
Hi. How can I create a vector<bool> efficiently from a char* or a vector<char> ? For example, if char* c == (8,10) I want vector<bool> v to be: (0000100000001010)
4
5319
by: Jeff Paciga | last post by:
I have been reading about the problems associated with vector<bool>. Unfortunately, the usual work-arounds aren't viable for me, but I have never seen anyone mention using a class that behaves like a bool: class FakeBool { public: FakeBool() : b_(false) {} FakeBool(bool b) : b_(b) {} operator bool() { return b_; }
12
1561
by: Christian Roth | last post by:
Hello, I am merely asking this for my own understanding: Processing instruction's data part is not entity-aware, i.e. character and numercial entities are not resolved at parsing time. E.g., <?mypi &lt;par/&gt; ?> delivers as data part the String(!) "&lt;par/&gt;".
16
2406
by: call_me_anything | last post by:
why is the following not allowed : vector <Base *vec_of_base; vector <Derived *vec_of_derived; vec_of_base = vec_of_derived; Note : The following is allowed :
11
4594
by: mathieu | last post by:
Hello, I would like to implement a 'vector<uint12_t>' structure, where uint12_t is a 12bits unsigned integer. AFAIK I need to completely duplicate the implementation of let say vector<booland adapt the code to suit my need. I cannot find out if there is way for me to reuse my vendor std::vector ? Suggestions welcome, Mathieu
8
3991
by: barcaroller | last post by:
I have a pointer to a memory block. Is there a way I can map a vector<Tto this memory block? I would like to take advantage of the powerful vector<T> member functions. Please note that I cannot copy the data into the vector because the memory block is used/read by other objects.
2
2610
by: vikasetrx | last post by:
any idea how we can cast from std::vector types. e.g.. i am using the win32 API RegQueryValueEx(). the out buffer it takes should be LPBYTE. i used the code as shown, TCHAR * buf = new TCHAR;
2
12202
by: blueflyy | last post by:
Hello, I wish to initialize a vector<BYTE> from an existing BYTE array. Simple example: BYTE buf = {0,1,2,3,4,5}; std::vector<BYTE> vec(buf, buf + sizeof(buf)/sizeof(buf));
0
9431
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9255
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10014
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9844
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
6514
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5119
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5289
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3780
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3326
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.