dbTalk Databases Forums  

Return string directly from the class ROW

mailing.database.mysql-plusplus mailing.database.mysql-plusplus


Discuss Return string directly from the class ROW in the mailing.database.mysql-plusplus forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Yingbo Miao
 
Posts: n/a

Default Return string directly from the class ROW - 08-03-2005 , 08:04 PM






Hi,=20


I wonder whether it is a good way to return the "raw string" directly=20
from the class ROW. For example, one line line can be added to the=20
row.h=20


class ROW ...=20
{=20
public:=20


// The suggestion function. Return the "raw string"=20
const std::string & raw_string ( int i ) const { return data.at(i); }=20



}=20


I find it is handy to handle the result of a blob column in this way.

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw


Reply With Quote
  #2  
Old   
Yingbo Miao
 
Posts: n/a

Default Re: Return string directly from the class ROW - 08-04-2005 , 10:27 AM






Oh, sorry. I copied wrong code from row.h. It should be:

const std::string & raw_string ( int i ) const {=20
return data.at(i);=20
}


On 8/4/05, P=E5l Brattberg <pal (AT) eminds (DOT) se> wrote:
Quote:
Yingbo Miao wrote:
I wonder whether it is a good way to return the "raw string" directly
from the class ROW. For example, one line line can be added to the row.h
=20
How about the following, already present i row.h?
=20
// Return the value of a field given its index, in raw form.
const char* raw_data(int i) const
{
return data_[i].data();
}
=20
What are you missing in this?
=20
/ p=E5l
=20
=20
=20
--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...gmail (DOT) c=
om
=20

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
  #3  
Old   
Yingbo Miao
 
Posts: n/a

Default Re: Return string directly from the class ROW - 08-04-2005 , 03:13 PM



Hi,

I misunderstood Pal's post. Sorry again for that.

Using raw_data(), we only get a char * without knowing the length of
it. In the mysql++ example, we see some "complicate" way to get the
length. I think we can avoid it by directly returning the std::string
object. That is why I suggest the new function *raw_string()*.

- Yingbo

On 8/4/05, Yingbo Miao <yingbo (AT) gmail (DOT) com> wrote:
Quote:
Oh, sorry. I copied wrong code from row.h. It should be:
=20
const std::string & raw_string ( int i ) const {
return data.at(i);
}
=20
=20
On 8/4/05, P=E5l Brattberg <pal (AT) eminds (DOT) se> wrote:
Yingbo Miao wrote:
I wonder whether it is a good way to return the "raw string" directl=
y
from the class ROW. For example, one line line can be added to the row.=
h

How about the following, already present i row.h?

// Return the value of a field given its index, in raw form.
const char* raw_data(int i) const
{
return data_[i].data();
}

What are you missing in this?

/ p=E5l

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
  #4  
Old   
Warren Young
 
Posts: n/a

Default Re: Return string directly from the class ROW - 01-12-2007 , 12:41 PM



Yingbo Miao wrote:
Quote:
I wonder whether it is a good way to return the "raw string" directly
from the class ROW. For example, one line line can be added to the
row.h


class ROW ...
{
public:


// The suggestion function. Return the "raw string"
const std::string & raw_string ( int i ) const { return data.at(i); }
Sorry for the long delay, but I've applied a patch for this. It'll
appear in MySQL++ 2.2. Thanks for the suggestion!

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.