MySQL++

Hex Artifact Content
Login

Hex Artifact Content

Artifact 45a3d9569eea39511ffb851e16dc42d2c2e19ccc800d49659cb2511bb77f6cad:


0000: 2f 2f 2f 20 5c 66 69 6c 65 20 72 65 73 75 6c 74  /// \file result
0010: 2e 68 0a 2f 2f 2f 20 5c 62 72 69 65 66 20 44 65  .h./// \brief De
0020: 63 6c 61 72 65 73 20 63 6c 61 73 73 65 73 20 66  clares classes f
0030: 6f 72 20 68 6f 6c 64 69 6e 67 20 69 6e 66 6f 72  or holding infor
0040: 6d 61 74 69 6f 6e 20 61 62 6f 75 74 20 53 51 4c  mation about SQL
0050: 20 71 75 65 72 79 0a 2f 2f 2f 20 72 65 73 75 6c   query./// resul
0060: 74 73 2e 0a 0a 2f 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ts.../**********
0070: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0080: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0090: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
00a0: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 0a 20 43  *************. C
00b0: 6f 70 79 72 69 67 68 74 20 28 63 29 20 31 39 39  opyright (c) 199
00c0: 38 20 62 79 20 4b 65 76 69 6e 20 41 74 6b 69 6e  8 by Kevin Atkin
00d0: 73 6f 6e 2c 20 28 63 29 20 31 39 39 39 2d 32 30  son, (c) 1999-20
00e0: 30 31 20 62 79 20 4d 79 53 51 4c 20 41 42 2c 20  01 by MySQL AB, 
00f0: 61 6e 64 0a 20 28 63 29 20 32 30 30 34 2d 32 30  and. (c) 2004-20
0100: 30 37 20 62 79 20 45 64 75 63 61 74 69 6f 6e 61  07 by Educationa
0110: 6c 20 54 65 63 68 6e 6f 6c 6f 67 79 20 52 65 73  l Technology Res
0120: 6f 75 72 63 65 73 2c 20 49 6e 63 2e 20 20 4f 74  ources, Inc.  Ot
0130: 68 65 72 73 20 6d 61 79 0a 20 61 6c 73 6f 20 68  hers may. also h
0140: 6f 6c 64 20 63 6f 70 79 72 69 67 68 74 73 20 6f  old copyrights o
0150: 6e 20 63 6f 64 65 20 69 6e 20 74 68 69 73 20 66  n code in this f
0160: 69 6c 65 2e 20 20 53 65 65 20 74 68 65 20 43 52  ile.  See the CR
0170: 45 44 49 54 53 2e 74 78 74 20 66 69 6c 65 0a 20  EDITS.txt file. 
0180: 69 6e 20 74 68 65 20 74 6f 70 20 64 69 72 65 63  in the top direc
0190: 74 6f 72 79 20 6f 66 20 74 68 65 20 64 69 73 74  tory of the dist
01a0: 72 69 62 75 74 69 6f 6e 20 66 6f 72 20 64 65 74  ribution for det
01b0: 61 69 6c 73 2e 0a 0a 20 54 68 69 73 20 66 69 6c  ails... This fil
01c0: 65 20 69 73 20 70 61 72 74 20 6f 66 20 4d 79 53  e is part of MyS
01d0: 51 4c 2b 2b 2e 0a 0a 20 4d 79 53 51 4c 2b 2b 20  QL++... MySQL++ 
01e0: 69 73 20 66 72 65 65 20 73 6f 66 74 77 61 72 65  is free software
01f0: 3b 20 79 6f 75 20 63 61 6e 20 72 65 64 69 73 74  ; you can redist
0200: 72 69 62 75 74 65 20 69 74 20 61 6e 64 2f 6f 72  ribute it and/or
0210: 20 6d 6f 64 69 66 79 20 69 74 0a 20 75 6e 64 65   modify it. unde
0220: 72 20 74 68 65 20 74 65 72 6d 73 20 6f 66 20 74  r the terms of t
0230: 68 65 20 47 4e 55 20 4c 65 73 73 65 72 20 47 65  he GNU Lesser Ge
0240: 6e 65 72 61 6c 20 50 75 62 6c 69 63 20 4c 69 63  neral Public Lic
0250: 65 6e 73 65 20 61 73 20 70 75 62 6c 69 73 68 65  ense as publishe
0260: 64 0a 20 62 79 20 74 68 65 20 46 72 65 65 20 53  d. by the Free S
0270: 6f 66 74 77 61 72 65 20 46 6f 75 6e 64 61 74 69  oftware Foundati
0280: 6f 6e 3b 20 65 69 74 68 65 72 20 76 65 72 73 69  on; either versi
0290: 6f 6e 20 32 2e 31 20 6f 66 20 74 68 65 20 4c 69  on 2.1 of the Li
02a0: 63 65 6e 73 65 2c 20 6f 72 0a 20 28 61 74 20 79  cense, or. (at y
02b0: 6f 75 72 20 6f 70 74 69 6f 6e 29 20 61 6e 79 20  our option) any 
02c0: 6c 61 74 65 72 20 76 65 72 73 69 6f 6e 2e 0a 0a  later version...
02d0: 20 4d 79 53 51 4c 2b 2b 20 69 73 20 64 69 73 74   MySQL++ is dist
02e0: 72 69 62 75 74 65 64 20 69 6e 20 74 68 65 20 68  ributed in the h
02f0: 6f 70 65 20 74 68 61 74 20 69 74 20 77 69 6c 6c  ope that it will
0300: 20 62 65 20 75 73 65 66 75 6c 2c 20 62 75 74 20   be useful, but 
0310: 57 49 54 48 4f 55 54 0a 20 41 4e 59 20 57 41 52  WITHOUT. ANY WAR
0320: 52 41 4e 54 59 3b 20 77 69 74 68 6f 75 74 20 65  RANTY; without e
0330: 76 65 6e 20 74 68 65 20 69 6d 70 6c 69 65 64 20  ven the implied 
0340: 77 61 72 72 61 6e 74 79 20 6f 66 20 4d 45 52 43  warranty of MERC
0350: 48 41 4e 54 41 42 49 4c 49 54 59 20 6f 72 0a 20  HANTABILITY or. 
0360: 46 49 54 4e 45 53 53 20 46 4f 52 20 41 20 50 41  FITNESS FOR A PA
0370: 52 54 49 43 55 4c 41 52 20 50 55 52 50 4f 53 45  RTICULAR PURPOSE
0380: 2e 20 20 53 65 65 20 74 68 65 20 47 4e 55 20 4c  .  See the GNU L
0390: 65 73 73 65 72 20 47 65 6e 65 72 61 6c 20 50 75  esser General Pu
03a0: 62 6c 69 63 0a 20 4c 69 63 65 6e 73 65 20 66 6f  blic. License fo
03b0: 72 20 6d 6f 72 65 20 64 65 74 61 69 6c 73 2e 0a  r more details..
03c0: 0a 20 59 6f 75 20 73 68 6f 75 6c 64 20 68 61 76  . You should hav
03d0: 65 20 72 65 63 65 69 76 65 64 20 61 20 63 6f 70  e received a cop
03e0: 79 20 6f 66 20 74 68 65 20 47 4e 55 20 4c 65 73  y of the GNU Les
03f0: 73 65 72 20 47 65 6e 65 72 61 6c 20 50 75 62 6c  ser General Publ
0400: 69 63 0a 20 4c 69 63 65 6e 73 65 20 61 6c 6f 6e  ic. License alon
0410: 67 20 77 69 74 68 20 4d 79 53 51 4c 2b 2b 3b 20  g with MySQL++; 
0420: 69 66 20 6e 6f 74 2c 20 77 72 69 74 65 20 74 6f  if not, write to
0430: 20 74 68 65 20 46 72 65 65 20 53 6f 66 74 77 61   the Free Softwa
0440: 72 65 0a 20 46 6f 75 6e 64 61 74 69 6f 6e 2c 20  re. Foundation, 
0450: 49 6e 63 2e 2c 20 35 31 20 46 72 61 6e 6b 6c 69  Inc., 51 Frankli
0460: 6e 20 53 74 2c 20 46 69 66 74 68 20 46 6c 6f 6f  n St, Fifth Floo
0470: 72 2c 20 42 6f 73 74 6f 6e 2c 20 4d 41 20 30 32  r, Boston, MA 02
0480: 31 31 30 2d 31 33 30 31 0a 20 55 53 41 0a 2a 2a  110-1301. USA.**
0490: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
04a0: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
04b0: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
04c0: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
04d0: 2a 2a 2a 2a 2a 2f 0a 0a 23 69 66 20 21 64 65 66  *****/..#if !def
04e0: 69 6e 65 64 28 4d 59 53 51 4c 50 50 5f 52 45 53  ined(MYSQLPP_RES
04f0: 55 4c 54 5f 48 29 0a 23 64 65 66 69 6e 65 20 4d  ULT_H).#define M
0500: 59 53 51 4c 50 50 5f 52 45 53 55 4c 54 5f 48 0a  YSQLPP_RESULT_H.
0510: 0a 23 69 6e 63 6c 75 64 65 20 22 63 6f 6d 6d 6f  .#include "commo
0520: 6e 2e 68 22 0a 0a 23 69 6e 63 6c 75 64 65 20 22  n.h"..#include "
0530: 65 78 63 65 70 74 69 6f 6e 73 2e 68 22 0a 23 69  exceptions.h".#i
0540: 6e 63 6c 75 64 65 20 22 66 69 65 6c 64 2e 68 22  nclude "field.h"
0550: 0a 23 69 6e 63 6c 75 64 65 20 22 66 69 65 6c 64  .#include "field
0560: 5f 6e 61 6d 65 73 2e 68 22 0a 23 69 6e 63 6c 75  _names.h".#inclu
0570: 64 65 20 22 66 69 65 6c 64 5f 74 79 70 65 73 2e  de "field_types.
0580: 68 22 0a 23 69 6e 63 6c 75 64 65 20 22 6e 6f 65  h".#include "noe
0590: 78 63 65 70 74 69 6f 6e 73 2e 68 22 0a 23 69 6e  xceptions.h".#in
05a0: 63 6c 75 64 65 20 22 72 65 66 63 6f 75 6e 74 65  clude "refcounte
05b0: 64 2e 68 22 0a 23 69 6e 63 6c 75 64 65 20 22 72  d.h".#include "r
05c0: 6f 77 2e 68 22 0a 0a 6e 61 6d 65 73 70 61 63 65  ow.h"..namespace
05d0: 20 6d 79 73 71 6c 70 70 20 7b 0a 0a 0a 2f 2f 2f   mysqlpp {...///
05e0: 20 5c 62 72 69 65 66 20 48 6f 6c 64 73 20 69 6e   \brief Holds in
05f0: 66 6f 72 6d 61 74 69 6f 6e 20 61 62 6f 75 74 20  formation about 
0600: 74 68 65 20 72 65 73 75 6c 74 20 6f 66 20 71 75  the result of qu
0610: 65 72 69 65 73 20 74 68 61 74 20 64 6f 6e 27 74  eries that don't
0620: 0a 2f 2f 2f 20 72 65 74 75 72 6e 20 72 6f 77 73  ./// return rows
0630: 2e 0a 0a 63 6c 61 73 73 20 4d 59 53 51 4c 50 50  ...class MYSQLPP
0640: 5f 45 58 50 4f 52 54 20 53 69 6d 70 6c 65 52 65  _EXPORT SimpleRe
0650: 73 75 6c 74 0a 7b 0a 70 72 69 76 61 74 65 3a 0a  sult.{.private:.
0660: 09 2f 2f 2f 20 5c 62 72 69 65 66 20 50 6f 69 6e  ./// \brief Poin
0670: 74 65 72 20 74 6f 20 62 6f 6f 6c 20 64 61 74 61  ter to bool data
0680: 20 6d 65 6d 62 65 72 2c 20 66 6f 72 20 75 73 65   member, for use
0690: 20 62 79 20 73 61 66 65 20 62 6f 6f 6c 0a 09 2f   by safe bool../
06a0: 2f 2f 20 63 6f 6e 76 65 72 73 69 6f 6e 20 6f 70  // conversion op
06b0: 65 72 61 74 6f 72 2e 0a 09 2f 2f 2f 0a 09 2f 2f  erator...///..//
06c0: 2f 20 5c 73 65 65 20 68 74 74 70 3a 2f 2f 77 77  / \see http://ww
06d0: 77 2e 61 72 74 69 6d 61 2e 63 6f 6d 2f 63 70 70  w.artima.com/cpp
06e0: 73 6f 75 72 63 65 2f 73 61 66 65 62 6f 6f 6c 2e  source/safebool.
06f0: 68 74 6d 6c 0a 09 74 79 70 65 64 65 66 20 62 6f  html..typedef bo
0700: 6f 6c 20 53 69 6d 70 6c 65 52 65 73 75 6c 74 3a  ol SimpleResult:
0710: 3a 2a 70 72 69 76 61 74 65 5f 62 6f 6f 6c 5f 74  :*private_bool_t
0720: 79 70 65 3b 0a 0a 70 75 62 6c 69 63 3a 0a 09 2f  ype;..public:../
0730: 2f 2f 20 5c 62 72 69 65 66 20 44 65 66 61 75 6c  // \brief Defaul
0740: 74 20 63 74 6f 72 0a 09 53 69 6d 70 6c 65 52 65  t ctor..SimpleRe
0750: 73 75 6c 74 28 29 20 3a 0a 09 63 6f 70 61 63 65  sult() :..copace
0760: 74 69 63 5f 28 66 61 6c 73 65 29 2c 0a 09 69 6e  tic_(false),..in
0770: 73 65 72 74 5f 69 64 5f 28 30 29 2c 0a 09 72 6f  sert_id_(0),..ro
0780: 77 73 5f 28 30 29 0a 09 7b 0a 09 7d 0a 0a 09 2f  ws_(0)..{..}.../
0790: 2f 2f 20 5c 62 72 69 65 66 20 49 6e 69 74 69 61  // \brief Initia
07a0: 6c 69 7a 65 20 6f 62 6a 65 63 74 0a 09 53 69 6d  lize object..Sim
07b0: 70 6c 65 52 65 73 75 6c 74 28 62 6f 6f 6c 20 63  pleResult(bool c
07c0: 6f 70 61 63 65 74 69 63 2c 20 75 6c 6f 6e 67 6c  opacetic, ulongl
07d0: 6f 6e 67 20 69 6e 73 65 72 74 5f 69 64 2c 0a 09  ong insert_id,..
07e0: 09 09 75 6c 6f 6e 67 6c 6f 6e 67 20 72 6f 77 73  ..ulonglong rows
07f0: 2c 20 63 6f 6e 73 74 20 73 74 64 3a 3a 73 74 72  , const std::str
0800: 69 6e 67 26 20 69 6e 66 6f 29 20 3a 0a 09 63 6f  ing& info) :..co
0810: 70 61 63 65 74 69 63 5f 28 63 6f 70 61 63 65 74  pacetic_(copacet
0820: 69 63 29 2c 0a 09 69 6e 73 65 72 74 5f 69 64 5f  ic),..insert_id_
0830: 28 69 6e 73 65 72 74 5f 69 64 29 2c 0a 09 72 6f  (insert_id),..ro
0840: 77 73 5f 28 72 6f 77 73 29 2c 0a 09 69 6e 66 6f  ws_(rows),..info
0850: 5f 28 69 6e 66 6f 29 0a 09 7b 0a 09 7d 0a 0a 09  _(info)..{..}...
0860: 2f 2f 2f 20 5c 62 72 69 65 66 20 54 65 73 74 20  /// \brief Test 
0870: 77 68 65 74 68 65 72 20 74 68 65 20 71 75 65 72  whether the quer
0880: 79 20 74 68 61 74 20 63 72 65 61 74 65 64 20 74  y that created t
0890: 68 69 73 20 72 65 73 75 6c 74 20 73 75 63 63 65  his result succe
08a0: 65 64 65 64 0a 09 2f 2f 2f 0a 09 2f 2f 2f 20 49  eded..///../// I
08b0: 66 20 79 6f 75 20 74 65 73 74 20 74 68 69 73 20  f you test this 
08c0: 6f 62 6a 65 63 74 20 69 6e 20 62 6f 6f 6c 20 63  object in bool c
08d0: 6f 6e 74 65 78 74 20 61 6e 64 20 69 74 27 73 20  ontext and it's 
08e0: 66 61 6c 73 65 2c 20 69 74 27 73 20 61 0a 09 2f  false, it's a../
08f0: 2f 2f 20 73 69 67 6e 61 6c 20 74 68 61 74 20 74  // signal that t
0900: 68 65 20 71 75 65 72 79 20 74 68 69 73 20 77 61  he query this wa
0910: 73 20 63 72 65 61 74 65 64 20 66 72 6f 6d 20 66  s created from f
0920: 61 69 6c 65 64 20 69 6e 20 73 6f 6d 65 20 77 61  ailed in some wa
0930: 79 2e 0a 09 2f 2f 2f 20 43 61 6c 6c 20 51 75 65  y.../// Call Que
0940: 72 79 3a 3a 65 72 72 6f 72 28 29 20 6f 72 20 51  ry::error() or Q
0950: 75 65 72 79 3a 3a 65 72 72 6e 75 6d 28 29 20 74  uery::errnum() t
0960: 6f 20 66 69 6e 64 20 6f 75 74 20 77 68 61 74 20  o find out what 
0970: 65 78 61 63 74 6c 79 0a 09 2f 2f 2f 20 68 61 70  exactly../// hap
0980: 70 65 6e 65 64 2e 0a 09 6f 70 65 72 61 74 6f 72  pened...operator
0990: 20 70 72 69 76 61 74 65 5f 62 6f 6f 6c 5f 74 79   private_bool_ty
09a0: 70 65 28 29 20 63 6f 6e 73 74 0a 09 7b 0a 09 09  pe() const..{...
09b0: 72 65 74 75 72 6e 20 63 6f 70 61 63 65 74 69 63  return copacetic
09c0: 5f 20 3f 20 26 53 69 6d 70 6c 65 52 65 73 75 6c  _ ? &SimpleResul
09d0: 74 3a 3a 63 6f 70 61 63 65 74 69 63 5f 20 3a 20  t::copacetic_ : 
09e0: 30 3b 0a 09 7d 0a 0a 09 2f 2f 2f 20 5c 62 72 69  0;..}.../// \bri
09f0: 65 66 20 47 65 74 20 74 68 65 20 6c 61 73 74 20  ef Get the last 
0a00: 76 61 6c 75 65 20 75 73 65 64 20 66 6f 72 20 61  value used for a
0a10: 6e 20 41 55 54 4f 5f 49 4e 43 52 45 4d 45 4e 54  n AUTO_INCREMENT
0a20: 20 66 69 65 6c 64 0a 09 75 6c 6f 6e 67 6c 6f 6e   field..ulonglon
0a30: 67 20 69 6e 73 65 72 74 5f 69 64 28 29 20 63 6f  g insert_id() co
0a40: 6e 73 74 20 7b 20 72 65 74 75 72 6e 20 69 6e 73  nst { return ins
0a50: 65 72 74 5f 69 64 5f 3b 20 7d 0a 0a 09 2f 2f 2f  ert_id_; }...///
0a60: 20 5c 62 72 69 65 66 20 47 65 74 20 74 68 65 20   \brief Get the 
0a70: 6e 75 6d 62 65 72 20 6f 66 20 72 6f 77 73 20 61  number of rows a
0a80: 66 66 65 63 74 65 64 20 62 79 20 74 68 65 20 71  ffected by the q
0a90: 75 65 72 79 0a 09 75 6c 6f 6e 67 6c 6f 6e 67 20  uery..ulonglong 
0aa0: 72 6f 77 73 28 29 20 63 6f 6e 73 74 20 7b 20 72  rows() const { r
0ab0: 65 74 75 72 6e 20 72 6f 77 73 5f 3b 20 7d 0a 0a  eturn rows_; }..
0ac0: 09 2f 2f 2f 20 5c 62 72 69 65 66 20 47 65 74 20  ./// \brief Get 
0ad0: 61 6e 79 20 61 64 64 69 74 69 6f 6e 61 6c 20 69  any additional i
0ae0: 6e 66 6f 72 6d 61 74 69 6f 6e 20 61 62 6f 75 74  nformation about
0af0: 20 74 68 65 20 71 75 65 72 79 20 72 65 74 75 72   the query retur
0b00: 6e 65 64 0a 09 2f 2f 2f 20 62 79 20 74 68 65 20  ned../// by the 
0b10: 73 65 72 76 65 72 2e 0a 09 63 6f 6e 73 74 20 63  server...const c
0b20: 68 61 72 2a 20 69 6e 66 6f 28 29 20 63 6f 6e 73  har* info() cons
0b30: 74 20 7b 20 72 65 74 75 72 6e 20 69 6e 66 6f 5f  t { return info_
0b40: 2e 63 5f 73 74 72 28 29 3b 20 7d 0a 0a 70 72 69  .c_str(); }..pri
0b50: 76 61 74 65 3a 0a 09 62 6f 6f 6c 20 63 6f 70 61  vate:..bool copa
0b60: 63 65 74 69 63 5f 3b 0a 09 75 6c 6f 6e 67 6c 6f  cetic_;..ulonglo
0b70: 6e 67 20 69 6e 73 65 72 74 5f 69 64 5f 3b 0a 09  ng insert_id_;..
0b80: 75 6c 6f 6e 67 6c 6f 6e 67 20 72 6f 77 73 5f 3b  ulonglong rows_;
0b90: 0a 09 73 74 64 3a 3a 73 74 72 69 6e 67 20 69 6e  ..std::string in
0ba0: 66 6f 5f 3b 0a 7d 3b 0a 0a 0a 2f 2f 2f 20 5c 62  fo_;.};.../// \b
0bb0: 72 69 65 66 20 42 61 73 65 20 63 6c 61 73 73 20  rief Base class 
0bc0: 66 6f 72 20 53 74 6f 72 65 51 75 65 72 79 52 65  for StoreQueryRe
0bd0: 73 75 6c 74 20 61 6e 64 20 55 73 65 51 75 65 72  sult and UseQuer
0be0: 79 52 65 73 75 6c 74 2e 0a 2f 2f 2f 0a 2f 2f 2f  yResult..///.///
0bf0: 20 4e 6f 74 20 75 73 65 66 75 6c 20 64 69 72 65   Not useful dire
0c00: 63 74 6c 79 2e 20 20 4a 75 73 74 20 63 6f 6e 74  ctly.  Just cont
0c10: 61 69 6e 73 20 63 6f 6d 6d 6f 6e 20 66 75 6e 63  ains common func
0c20: 74 69 6f 6e 61 6c 69 74 79 20 66 6f 72 20 69 74  tionality for it
0c30: 73 0a 2f 2f 2f 20 73 75 62 63 6c 61 73 73 65 73  s./// subclasses
0c40: 2e 0a 0a 63 6c 61 73 73 20 4d 59 53 51 4c 50 50  ...class MYSQLPP
0c50: 5f 45 58 50 4f 52 54 20 52 65 73 75 6c 74 42 61  _EXPORT ResultBa
0c60: 73 65 20 3a 20 70 75 62 6c 69 63 20 4f 70 74 69  se : public Opti
0c70: 6f 6e 61 6c 45 78 63 65 70 74 69 6f 6e 73 0a 7b  onalExceptions.{
0c80: 0a 70 75 62 6c 69 63 3a 0a 09 2f 2f 2f 20 5c 62  .public:../// \b
0c90: 72 69 65 66 20 44 65 73 74 72 6f 79 20 6f 62 6a  rief Destroy obj
0ca0: 65 63 74 0a 09 76 69 72 74 75 61 6c 20 7e 52 65  ect..virtual ~Re
0cb0: 73 75 6c 74 42 61 73 65 28 29 20 7b 20 7d 0a 0a  sultBase() { }..
0cc0: 09 2f 2f 2f 20 5c 62 72 69 65 66 20 52 65 74 75  ./// \brief Retu
0cd0: 72 6e 73 20 74 68 65 20 6e 65 78 74 20 66 69 65  rns the next fie
0ce0: 6c 64 20 69 6e 20 74 68 69 73 20 72 65 73 75 6c  ld in this resul
0cf0: 74 20 73 65 74 0a 09 63 6f 6e 73 74 20 46 69 65  t set..const Fie
0d00: 6c 64 26 20 66 65 74 63 68 5f 66 69 65 6c 64 28  ld& fetch_field(
0d10: 29 20 63 6f 6e 73 74 0a 09 09 09 7b 20 72 65 74  ) const....{ ret
0d20: 75 72 6e 20 66 69 65 6c 64 73 5f 2e 61 74 28 63  urn fields_.at(c
0d30: 75 72 72 65 6e 74 5f 66 69 65 6c 64 5f 2b 2b 29  urrent_field_++)
0d40: 3b 20 7d 0a 0a 09 2f 2f 2f 20 5c 62 72 69 65 66  ; }.../// \brief
0d50: 20 52 65 74 75 72 6e 73 20 74 68 65 20 67 69 76   Returns the giv
0d60: 65 6e 20 66 69 65 6c 64 20 69 6e 20 74 68 69 73  en field in this
0d70: 20 72 65 73 75 6c 74 20 73 65 74 0a 09 63 6f 6e   result set..con
0d80: 73 74 20 46 69 65 6c 64 26 20 66 65 74 63 68 5f  st Field& fetch_
0d90: 66 69 65 6c 64 28 46 69 65 6c 64 73 3a 3a 73 69  field(Fields::si
0da0: 7a 65 5f 74 79 70 65 20 69 29 20 63 6f 6e 73 74  ze_type i) const
0db0: 0a 09 09 09 7b 20 72 65 74 75 72 6e 20 66 69 65  ....{ return fie
0dc0: 6c 64 73 5f 2e 61 74 28 69 29 3b 20 7d 0a 0a 09  lds_.at(i); }...
0dd0: 2f 2f 2f 20 5c 62 72 69 65 66 20 47 65 74 20 74  /// \brief Get t
0de0: 68 65 20 75 6e 64 65 72 6c 79 69 6e 67 20 46 69  he underlying Fi
0df0: 65 6c 64 20 73 74 72 75 63 74 75 72 65 20 67 69  eld structure gi
0e00: 76 65 6e 20 69 74 73 20 69 6e 64 65 78 2e 0a 09  ven its index...
0e10: 63 6f 6e 73 74 20 46 69 65 6c 64 26 20 66 69 65  const Field& fie
0e20: 6c 64 28 75 6e 73 69 67 6e 65 64 20 69 6e 74 20  ld(unsigned int 
0e30: 69 29 20 63 6f 6e 73 74 20 7b 20 72 65 74 75 72  i) const { retur
0e40: 6e 20 66 69 65 6c 64 73 5f 2e 61 74 28 69 29 3b  n fields_.at(i);
0e50: 20 7d 0a 0a 09 2f 2f 2f 20 5c 62 72 69 65 66 20   }.../// \brief 
0e60: 47 65 74 20 74 68 65 20 75 6e 64 65 72 6c 79 69  Get the underlyi
0e70: 6e 67 20 46 69 65 6c 64 73 20 73 74 72 75 63 74  ng Fields struct
0e80: 75 72 65 2e 0a 09 63 6f 6e 73 74 20 46 69 65 6c  ure...const Fiel
0e90: 64 73 26 20 66 69 65 6c 64 73 28 29 20 63 6f 6e  ds& fields() con
0ea0: 73 74 20 7b 20 72 65 74 75 72 6e 20 66 69 65 6c  st { return fiel
0eb0: 64 73 5f 3b 20 7d 0a 0a 09 2f 2f 2f 20 5c 62 72  ds_; }.../// \br
0ec0: 69 65 66 20 47 65 74 20 74 68 65 20 6e 61 6d 65  ief Get the name
0ed0: 20 6f 66 20 74 68 65 20 66 69 65 6c 64 20 61 74   of the field at
0ee0: 20 74 68 65 20 67 69 76 65 6e 20 69 6e 64 65 78   the given index
0ef0: 2e 0a 09 63 6f 6e 73 74 20 73 74 64 3a 3a 73 74  ...const std::st
0f00: 72 69 6e 67 26 20 66 69 65 6c 64 5f 6e 61 6d 65  ring& field_name
0f10: 28 69 6e 74 20 69 29 20 63 6f 6e 73 74 0a 09 09  (int i) const...
0f20: 09 7b 20 72 65 74 75 72 6e 20 6e 61 6d 65 73 5f  .{ return names_
0f30: 2d 3e 61 74 28 69 29 3b 20 7d 0a 0a 09 2f 2f 2f  ->at(i); }...///
0f40: 20 5c 62 72 69 65 66 20 47 65 74 20 74 68 65 20   \brief Get the 
0f50: 6e 61 6d 65 73 20 6f 66 20 74 68 65 20 66 69 65  names of the fie
0f60: 6c 64 73 20 77 69 74 68 69 6e 20 74 68 69 73 20  lds within this 
0f70: 72 65 73 75 6c 74 20 73 65 74 2e 0a 09 63 6f 6e  result set...con
0f80: 73 74 20 52 65 66 43 6f 75 6e 74 65 64 50 6f 69  st RefCountedPoi
0f90: 6e 74 65 72 3c 46 69 65 6c 64 4e 61 6d 65 73 3e  nter<FieldNames>
0fa0: 26 20 66 69 65 6c 64 5f 6e 61 6d 65 73 28 29 20  & field_names() 
0fb0: 63 6f 6e 73 74 0a 09 09 09 7b 20 72 65 74 75 72  const....{ retur
0fc0: 6e 20 6e 61 6d 65 73 5f 3b 20 7d 0a 0a 09 2f 2f  n names_; }...//
0fd0: 2f 20 5c 62 72 69 65 66 20 47 65 74 20 74 68 65  / \brief Get the
0fe0: 20 69 6e 64 65 78 20 6f 66 20 74 68 65 20 6e 61   index of the na
0ff0: 6d 65 64 20 66 69 65 6c 64 2e 0a 09 2f 2f 2f 0a  med field...///.
1000: 09 2f 2f 2f 20 54 68 69 73 20 69 73 20 74 68 65  ./// This is the
1010: 20 69 6e 76 65 72 73 65 20 6f 66 20 66 69 65 6c   inverse of fiel
1020: 64 5f 6e 61 6d 65 28 29 2e 0a 09 69 6e 74 20 66  d_name()...int f
1030: 69 65 6c 64 5f 6e 75 6d 28 63 6f 6e 73 74 20 73  ield_num(const s
1040: 74 64 3a 3a 73 74 72 69 6e 67 26 29 20 63 6f 6e  td::string&) con
1050: 73 74 3b 0a 0a 09 2f 2f 2f 20 5c 62 72 69 65 66  st;.../// \brief
1060: 20 47 65 74 20 74 68 65 20 74 79 70 65 20 6f 66   Get the type of
1070: 20 61 20 70 61 72 74 69 63 75 6c 61 72 20 66 69   a particular fi
1080: 65 6c 64 20 77 69 74 68 69 6e 20 74 68 69 73 20  eld within this 
1090: 72 65 73 75 6c 74 20 73 65 74 2e 0a 09 63 6f 6e  result set...con
10a0: 73 74 20 46 69 65 6c 64 54 79 70 65 73 3a 3a 76  st FieldTypes::v
10b0: 61 6c 75 65 5f 74 79 70 65 26 20 66 69 65 6c 64  alue_type& field
10c0: 5f 74 79 70 65 28 69 6e 74 20 69 29 20 63 6f 6e  _type(int i) con
10d0: 73 74 0a 09 09 09 7b 20 72 65 74 75 72 6e 20 74  st....{ return t
10e0: 79 70 65 73 5f 2d 3e 61 74 28 69 29 3b 20 7d 0a  ypes_->at(i); }.
10f0: 0a 09 2f 2f 2f 20 5c 62 72 69 65 66 20 47 65 74  ../// \brief Get
1100: 20 61 20 6c 69 73 74 20 6f 66 20 74 68 65 20 74   a list of the t
1110: 79 70 65 73 20 6f 66 20 74 68 65 20 66 69 65 6c  ypes of the fiel
1120: 64 73 20 77 69 74 68 69 6e 20 74 68 69 73 0a 09  ds within this..
1130: 2f 2f 2f 20 72 65 73 75 6c 74 20 73 65 74 2e 0a  /// result set..
1140: 09 63 6f 6e 73 74 20 52 65 66 43 6f 75 6e 74 65  .const RefCounte
1150: 64 50 6f 69 6e 74 65 72 3c 46 69 65 6c 64 54 79  dPointer<FieldTy
1160: 70 65 73 3e 26 20 66 69 65 6c 64 5f 74 79 70 65  pes>& field_type
1170: 73 28 29 20 63 6f 6e 73 74 0a 09 09 09 7b 20 72  s() const....{ r
1180: 65 74 75 72 6e 20 74 79 70 65 73 5f 3b 20 7d 0a  eturn types_; }.
1190: 0a 09 2f 2f 2f 20 5c 62 72 69 65 66 20 52 65 74  ../// \brief Ret
11a0: 75 72 6e 73 20 74 68 65 20 6e 75 6d 62 65 72 20  urns the number 
11b0: 6f 66 20 66 69 65 6c 64 73 20 69 6e 20 74 68 69  of fields in thi
11c0: 73 20 72 65 73 75 6c 74 20 73 65 74 0a 09 73 69  s result set..si
11d0: 7a 65 5f 74 20 6e 75 6d 5f 66 69 65 6c 64 73 28  ze_t num_fields(
11e0: 29 20 63 6f 6e 73 74 20 7b 20 72 65 74 75 72 6e  ) const { return
11f0: 20 66 69 65 6c 64 73 5f 2e 73 69 7a 65 28 29 3b   fields_.size();
1200: 20 7d 0a 0a 09 2f 2f 2f 20 5c 62 72 69 65 66 20   }.../// \brief 
1210: 52 65 74 75 72 6e 20 74 68 65 20 6e 61 6d 65 20  Return the name 
1220: 6f 66 20 74 68 65 20 74 61 62 6c 65 20 74 68 65  of the table the
1230: 20 72 65 73 75 6c 74 20 73 65 74 20 63 6f 6d 65   result set come
1240: 73 20 66 72 6f 6d 0a 09 63 6f 6e 73 74 20 63 68  s from..const ch
1250: 61 72 2a 20 74 61 62 6c 65 28 29 20 63 6f 6e 73  ar* table() cons
1260: 74 0a 09 09 09 7b 20 72 65 74 75 72 6e 20 66 69  t....{ return fi
1270: 65 6c 64 73 5f 2e 65 6d 70 74 79 28 29 20 3f 20  elds_.empty() ? 
1280: 22 22 20 3a 20 66 69 65 6c 64 73 5f 5b 30 5d 2e  "" : fields_[0].
1290: 74 61 62 6c 65 28 29 3b 20 7d 0a 0a 70 72 6f 74  table(); }..prot
12a0: 65 63 74 65 64 3a 0a 09 2f 2f 2f 20 5c 62 72 69  ected:../// \bri
12b0: 65 66 20 43 72 65 61 74 65 20 65 6d 70 74 79 20  ef Create empty 
12c0: 6f 62 6a 65 63 74 0a 09 52 65 73 75 6c 74 42 61  object..ResultBa
12d0: 73 65 28 29 20 3a 0a 09 64 72 69 76 65 72 5f 28  se() :..driver_(
12e0: 30 29 2c 0a 09 63 75 72 72 65 6e 74 5f 66 69 65  0),..current_fie
12f0: 6c 64 5f 28 30 29 0a 09 7b 0a 09 7d 0a 09 0a 09  ld_(0)..{..}....
1300: 2f 2f 2f 20 5c 62 72 69 65 66 20 43 72 65 61 74  /// \brief Creat
1310: 65 20 74 68 65 20 6f 62 6a 65 63 74 2c 20 66 75  e the object, fu
1320: 6c 6c 79 20 69 6e 69 74 69 61 6c 69 7a 65 64 0a  lly initialized.
1330: 09 52 65 73 75 6c 74 42 61 73 65 28 4d 59 53 51  .ResultBase(MYSQ
1340: 4c 5f 52 45 53 2a 20 72 65 73 75 6c 74 2c 20 44  L_RES* result, D
1350: 42 44 72 69 76 65 72 2a 20 64 62 64 2c 20 62 6f  BDriver* dbd, bo
1360: 6f 6c 20 74 65 20 3d 20 74 72 75 65 29 3b 0a 09  ol te = true);..
1370: 0a 09 2f 2f 2f 20 5c 62 72 69 65 66 20 43 72 65  ../// \brief Cre
1380: 61 74 65 20 6f 62 6a 65 63 74 20 61 73 20 61 20  ate object as a 
1390: 63 6f 70 79 20 6f 66 20 61 6e 6f 74 68 65 72 20  copy of another 
13a0: 52 65 73 75 6c 74 42 61 73 65 0a 09 52 65 73 75  ResultBase..Resu
13b0: 6c 74 42 61 73 65 28 63 6f 6e 73 74 20 52 65 73  ltBase(const Res
13c0: 75 6c 74 42 61 73 65 26 20 6f 74 68 65 72 29 20  ultBase& other) 
13d0: 3a 0a 09 4f 70 74 69 6f 6e 61 6c 45 78 63 65 70  :..OptionalExcep
13e0: 74 69 6f 6e 73 28 29 0a 09 7b 0a 09 09 63 6f 70  tions()..{...cop
13f0: 79 28 6f 74 68 65 72 29 3b 0a 09 7d 0a 0a 09 2f  y(other);..}.../
1400: 2f 2f 20 5c 62 72 69 65 66 20 43 6f 70 79 20 61  // \brief Copy a
1410: 6e 6f 74 68 65 72 20 52 65 73 75 6c 74 42 61 73  nother ResultBas
1420: 65 20 6f 62 6a 65 63 74 27 73 20 63 6f 6e 74 65  e object's conte
1430: 6e 74 73 20 69 6e 74 6f 20 74 68 69 73 20 6f 6e  nts into this on
1440: 65 2e 0a 09 52 65 73 75 6c 74 42 61 73 65 26 20  e...ResultBase& 
1450: 63 6f 70 79 28 63 6f 6e 73 74 20 52 65 73 75 6c  copy(const Resul
1460: 74 42 61 73 65 26 20 6f 74 68 65 72 29 3b 0a 0a  tBase& other);..
1470: 09 44 42 44 72 69 76 65 72 2a 20 64 72 69 76 65  .DBDriver* drive
1480: 72 5f 3b 09 2f 2f 2f 3c 20 41 63 63 65 73 73 20  r_;.///< Access 
1490: 74 6f 20 44 42 20 64 72 69 76 65 72 3b 20 66 75  to DB driver; fu
14a0: 6c 6c 79 20 69 6e 69 74 74 65 64 20 69 66 20 6e  lly initted if n
14b0: 6f 6e 7a 65 72 6f 0a 09 46 69 65 6c 64 73 20 66  onzero..Fields f
14c0: 69 65 6c 64 73 5f 3b 09 09 2f 2f 2f 3c 20 6c 69  ields_;..///< li
14d0: 73 74 20 6f 66 20 66 69 65 6c 64 73 20 69 6e 20  st of fields in 
14e0: 72 65 73 75 6c 74 0a 0a 09 2f 2f 2f 20 5c 62 72  result.../// \br
14f0: 69 65 66 20 6c 69 73 74 20 6f 66 20 66 69 65 6c  ief list of fiel
1500: 64 20 6e 61 6d 65 73 20 69 6e 20 72 65 73 75 6c  d names in resul
1510: 74 0a 09 52 65 66 43 6f 75 6e 74 65 64 50 6f 69  t..RefCountedPoi
1520: 6e 74 65 72 3c 46 69 65 6c 64 4e 61 6d 65 73 3e  nter<FieldNames>
1530: 20 6e 61 6d 65 73 5f 3b 0a 0a 09 2f 2f 2f 20 5c   names_;.../// \
1540: 62 72 69 65 66 20 6c 69 73 74 20 6f 66 20 66 69  brief list of fi
1550: 65 6c 64 20 74 79 70 65 73 20 69 6e 20 72 65 73  eld types in res
1560: 75 6c 74 0a 09 52 65 66 43 6f 75 6e 74 65 64 50  ult..RefCountedP
1570: 6f 69 6e 74 65 72 3c 46 69 65 6c 64 54 79 70 65  ointer<FieldType
1580: 73 3e 20 74 79 70 65 73 5f 3b 0a 0a 09 2f 2f 2f  s> types_;...///
1590: 20 5c 62 72 69 65 66 20 44 65 66 61 75 6c 74 20   \brief Default 
15a0: 66 69 65 6c 64 20 69 6e 64 65 78 20 75 73 65 64  field index used
15b0: 20 62 79 20 66 65 74 63 68 5f 66 69 65 6c 64 28   by fetch_field(
15c0: 29 0a 09 2f 2f 2f 0a 09 2f 2f 2f 20 49 74 27 73  )..///../// It's
15d0: 20 6d 75 74 61 62 6c 65 20 62 65 63 61 75 73 65   mutable because
15e0: 20 69 74 27 73 20 6a 75 73 74 20 69 6e 74 65 72   it's just inter
15f0: 6e 61 6c 20 68 6f 75 73 65 6b 65 65 70 69 6e 67  nal housekeeping
1600: 3a 20 69 74 27 73 0a 09 2f 2f 2f 20 63 68 61 6e  : it's../// chan
1610: 67 65 64 20 62 79 20 66 65 74 63 68 5f 66 69 65  ged by fetch_fie
1620: 6c 64 28 76 6f 69 64 29 2c 20 62 75 74 20 69 74  ld(void), but it
1630: 20 64 6f 65 73 6e 27 74 20 63 68 61 6e 67 65 20   doesn't change 
1640: 74 68 65 20 22 76 61 6c 75 65 22 0a 09 2f 2f 2f  the "value"..///
1650: 20 6f 66 20 74 68 65 20 72 65 73 75 6c 74 2e 20   of the result. 
1660: 20 53 65 65 20 6d 75 74 61 62 69 6c 69 74 79 20   See mutability 
1670: 6a 75 73 74 69 66 69 63 61 74 69 6f 6e 20 66 6f  justification fo
1680: 72 0a 09 2f 2f 2f 20 55 73 65 51 75 65 72 79 52  r../// UseQueryR
1690: 65 73 75 6c 74 3a 3a 72 65 73 75 6c 74 5f 3a 20  esult::result_: 
16a0: 74 68 69 73 20 66 69 65 6c 64 20 70 72 6f 76 69  this field provi
16b0: 64 65 73 20 66 75 6e 63 74 69 6f 6e 61 6c 69 74  des functionalit
16c0: 79 20 77 65 0a 09 2f 2f 2f 20 75 73 65 64 20 74  y we../// used t
16d0: 6f 20 67 65 74 20 74 68 72 6f 75 67 68 20 72 65  o get through re
16e0: 73 75 6c 74 5f 2c 20 73 6f 20 69 74 27 73 20 72  sult_, so it's r
16f0: 65 6c 65 76 61 6e 74 20 68 65 72 65 2c 20 74 6f  elevant here, to
1700: 6f 2e 0a 09 6d 75 74 61 62 6c 65 20 46 69 65 6c  o...mutable Fiel
1710: 64 73 3a 3a 73 69 7a 65 5f 74 79 70 65 20 63 75  ds::size_type cu
1720: 72 72 65 6e 74 5f 66 69 65 6c 64 5f 3b 0a 7d 3b  rrent_field_;.};
1730: 0a 0a 0a 2f 2f 2f 20 5c 62 72 69 65 66 20 53 74  .../// \brief St
1740: 6f 72 65 51 75 65 72 79 52 65 73 75 6c 74 20 73  oreQueryResult s
1750: 65 74 20 74 79 70 65 20 66 6f 72 20 22 73 74 6f  et type for "sto
1760: 72 65 22 20 71 75 65 72 69 65 73 0a 2f 2f 2f 0a  re" queries.///.
1770: 2f 2f 2f 20 54 68 69 73 20 69 73 20 74 68 65 20  /// This is the 
1780: 6f 62 76 69 6f 75 73 20 43 2b 2b 20 69 6d 70 6c  obvious C++ impl
1790: 65 6d 65 6e 74 61 74 69 6f 6e 20 6f 66 20 61 20  ementation of a 
17a0: 63 6c 61 73 73 20 74 6f 20 68 6f 6c 64 20 72 65  class to hold re
17b0: 73 75 6c 74 73 20 0a 2f 2f 2f 20 66 72 6f 6d 20  sults ./// from 
17c0: 61 20 53 51 4c 20 71 75 65 72 79 20 74 68 61 74  a SQL query that
17d0: 20 72 65 74 75 72 6e 73 20 72 6f 77 73 3a 20 61   returns rows: a
17e0: 20 73 70 65 63 69 61 6c 69 7a 61 74 69 6f 6e 20   specialization 
17f0: 6f 66 20 73 74 64 3a 3a 76 65 63 74 6f 72 0a 2f  of std::vector./
1800: 2f 2f 20 68 6f 6c 64 69 6e 67 20 52 6f 77 20 6f  // holding Row o
1810: 62 6a 65 63 74 73 20 69 6e 20 6d 65 6d 6f 72 79  bjects in memory
1820: 20 73 6f 20 79 6f 75 20 67 65 74 20 72 61 6e 64   so you get rand
1830: 6f 6d 2d 61 63 63 65 73 73 20 73 65 6d 61 6e 74  om-access semant
1840: 69 63 73 2e 0a 2f 2f 2f 20 4d 79 53 51 4c 2b 2b  ics../// MySQL++
1850: 20 61 6c 73 6f 20 73 75 70 70 6f 72 74 73 20 55   also supports U
1860: 73 65 51 75 65 72 79 52 65 73 75 6c 74 20 77 68  seQueryResult wh
1870: 69 63 68 20 69 73 20 6c 65 73 73 20 66 72 69 65  ich is less frie
1880: 6e 64 6c 79 2c 20 62 75 74 20 68 61 73 0a 2f 2f  ndly, but has.//
1890: 2f 20 62 65 74 74 65 72 20 6d 65 6d 6f 72 79 20  / better memory 
18a0: 70 65 72 66 6f 72 6d 61 6e 63 65 2e 20 20 53 65  performance.  Se
18b0: 65 20 74 68 65 20 75 73 65 72 20 6d 61 6e 75 61  e the user manua
18c0: 6c 20 66 6f 72 20 6d 6f 72 65 20 64 65 74 61 69  l for more detai
18d0: 6c 73 20 6f 6e 0a 2f 2f 2f 20 74 68 65 20 64 69  ls on./// the di
18e0: 73 74 69 6e 63 74 69 6f 6e 20 61 6e 64 20 74 68  stinction and th
18f0: 65 20 75 73 61 67 65 20 70 61 74 74 65 72 6e 73  e usage patterns
1900: 20 72 65 71 75 69 72 65 64 2e 0a 0a 63 6c 61 73   required...clas
1910: 73 20 4d 59 53 51 4c 50 50 5f 45 58 50 4f 52 54  s MYSQLPP_EXPORT
1920: 20 53 74 6f 72 65 51 75 65 72 79 52 65 73 75 6c   StoreQueryResul
1930: 74 20 3a 0a 09 09 70 75 62 6c 69 63 20 52 65 73  t :...public Res
1940: 75 6c 74 42 61 73 65 2c 0a 09 09 70 75 62 6c 69  ultBase,...publi
1950: 63 20 73 74 64 3a 3a 76 65 63 74 6f 72 3c 52 6f  c std::vector<Ro
1960: 77 3e 0a 7b 0a 70 72 69 76 61 74 65 3a 0a 09 2f  w>.{.private:../
1970: 2f 2f 20 5c 62 72 69 65 66 20 50 6f 69 6e 74 65  // \brief Pointe
1980: 72 20 74 6f 20 62 6f 6f 6c 20 64 61 74 61 20 6d  r to bool data m
1990: 65 6d 62 65 72 2c 20 66 6f 72 20 75 73 65 20 62  ember, for use b
19a0: 79 20 73 61 66 65 20 62 6f 6f 6c 0a 09 2f 2f 2f  y safe bool..///
19b0: 20 63 6f 6e 76 65 72 73 69 6f 6e 20 6f 70 65 72   conversion oper
19c0: 61 74 6f 72 2e 0a 09 2f 2f 2f 0a 09 2f 2f 2f 20  ator...///../// 
19d0: 5c 73 65 65 20 68 74 74 70 3a 2f 2f 77 77 77 2e  \see http://www.
19e0: 61 72 74 69 6d 61 2e 63 6f 6d 2f 63 70 70 73 6f  artima.com/cppso
19f0: 75 72 63 65 2f 73 61 66 65 62 6f 6f 6c 2e 68 74  urce/safebool.ht
1a00: 6d 6c 0a 09 74 79 70 65 64 65 66 20 62 6f 6f 6c  ml..typedef bool
1a10: 20 53 74 6f 72 65 51 75 65 72 79 52 65 73 75 6c   StoreQueryResul
1a20: 74 3a 3a 2a 70 72 69 76 61 74 65 5f 62 6f 6f 6c  t::*private_bool
1a30: 5f 74 79 70 65 3b 0a 0a 70 75 62 6c 69 63 3a 0a  _type;..public:.
1a40: 09 74 79 70 65 64 65 66 20 73 74 64 3a 3a 76 65  .typedef std::ve
1a50: 63 74 6f 72 3c 52 6f 77 3e 20 6c 69 73 74 5f 74  ctor<Row> list_t
1a60: 79 70 65 3b 09 2f 2f 2f 3c 20 74 79 70 65 20 6f  ype;.///< type o
1a70: 66 20 76 65 63 74 6f 72 20 62 61 73 65 20 63 6c  f vector base cl
1a80: 61 73 73 0a 0a 09 2f 2f 2f 20 5c 62 72 69 65 66  ass.../// \brief
1a90: 20 44 65 66 61 75 6c 74 20 63 6f 6e 73 74 72 75   Default constru
1aa0: 63 74 6f 72 0a 09 53 74 6f 72 65 51 75 65 72 79  ctor..StoreQuery
1ab0: 52 65 73 75 6c 74 28 29 20 3a 0a 09 52 65 73 75  Result() :..Resu
1ac0: 6c 74 42 61 73 65 28 29 2c 0a 09 63 6f 70 61 63  ltBase(),..copac
1ad0: 65 74 69 63 5f 28 66 61 6c 73 65 29 0a 09 7b 0a  etic_(false)..{.
1ae0: 09 7d 0a 09 0a 09 2f 2f 2f 20 5c 62 72 69 65 66  .}..../// \brief
1af0: 20 46 75 6c 6c 79 20 69 6e 69 74 69 61 6c 69 7a   Fully initializ
1b00: 65 20 6f 62 6a 65 63 74 0a 09 53 74 6f 72 65 51  e object..StoreQ
1b10: 75 65 72 79 52 65 73 75 6c 74 28 4d 59 53 51 4c  ueryResult(MYSQL
1b20: 5f 52 45 53 2a 20 72 65 73 75 6c 74 2c 20 44 42  _RES* result, DB
1b30: 44 72 69 76 65 72 2a 20 64 62 64 2c 20 62 6f 6f  Driver* dbd, boo
1b40: 6c 20 74 65 20 3d 20 74 72 75 65 29 3b 0a 0a 09  l te = true);...
1b50: 2f 2f 2f 20 5c 62 72 69 65 66 20 49 6e 69 74 69  /// \brief Initi
1b60: 61 6c 69 7a 65 20 6f 62 6a 65 63 74 20 61 73 20  alize object as 
1b70: 61 20 63 6f 70 79 20 6f 66 20 61 6e 6f 74 68 65  a copy of anothe
1b80: 72 20 53 74 6f 72 65 51 75 65 72 79 52 65 73 75  r StoreQueryResu
1b90: 6c 74 0a 09 2f 2f 2f 20 6f 62 6a 65 63 74 0a 09  lt../// object..
1ba0: 53 74 6f 72 65 51 75 65 72 79 52 65 73 75 6c 74  StoreQueryResult
1bb0: 28 63 6f 6e 73 74 20 53 74 6f 72 65 51 75 65 72  (const StoreQuer
1bc0: 79 52 65 73 75 6c 74 26 20 6f 74 68 65 72 29 20  yResult& other) 
1bd0: 3a 0a 09 52 65 73 75 6c 74 42 61 73 65 28 29 2c  :..ResultBase(),
1be0: 0a 09 73 74 64 3a 3a 76 65 63 74 6f 72 3c 52 6f  ..std::vector<Ro
1bf0: 77 3e 28 29 2c 0a 09 63 6f 70 61 63 65 74 69 63  w>(),..copacetic
1c00: 5f 28 66 61 6c 73 65 29 0a 09 7b 0a 09 09 63 6f  _(false)..{...co
1c10: 70 79 28 6f 74 68 65 72 29 3b 0a 09 7d 0a 0a 09  py(other);..}...
1c20: 2f 2f 2f 20 5c 62 72 69 65 66 20 44 65 73 74 72  /// \brief Destr
1c30: 6f 79 20 72 65 73 75 6c 74 20 73 65 74 0a 09 7e  oy result set..~
1c40: 53 74 6f 72 65 51 75 65 72 79 52 65 73 75 6c 74  StoreQueryResult
1c50: 28 29 20 7b 20 7d 0a 0a 09 2f 2f 2f 20 5c 62 72  () { }.../// \br
1c60: 69 65 66 20 52 65 74 75 72 6e 73 20 74 68 65 20  ief Returns the 
1c70: 6e 75 6d 62 65 72 20 6f 66 20 72 6f 77 73 20 69  number of rows i
1c80: 6e 20 74 68 69 73 20 72 65 73 75 6c 74 20 73 65  n this result se
1c90: 74 0a 09 6c 69 73 74 5f 74 79 70 65 3a 3a 73 69  t..list_type::si
1ca0: 7a 65 5f 74 79 70 65 20 6e 75 6d 5f 72 6f 77 73  ze_type num_rows
1cb0: 28 29 20 63 6f 6e 73 74 20 7b 20 72 65 74 75 72  () const { retur
1cc0: 6e 20 73 69 7a 65 28 29 3b 20 7d 0a 0a 09 2f 2f  n size(); }...//
1cd0: 2f 20 5c 62 72 69 65 66 20 43 6f 70 79 20 61 6e  / \brief Copy an
1ce0: 6f 74 68 65 72 20 53 74 6f 72 65 51 75 65 72 79  other StoreQuery
1cf0: 52 65 73 75 6c 74 20 6f 62 6a 65 63 74 27 73 20  Result object's 
1d00: 64 61 74 61 20 69 6e 74 6f 20 74 68 69 73 0a 09  data into this..
1d10: 2f 2f 2f 20 6f 62 6a 65 63 74 0a 09 53 74 6f 72  /// object..Stor
1d20: 65 51 75 65 72 79 52 65 73 75 6c 74 26 20 6f 70  eQueryResult& op
1d30: 65 72 61 74 6f 72 20 3d 28 63 6f 6e 73 74 20 53  erator =(const S
1d40: 74 6f 72 65 51 75 65 72 79 52 65 73 75 6c 74 26  toreQueryResult&
1d50: 20 72 68 73 29 0a 09 09 09 7b 20 72 65 74 75 72   rhs)....{ retur
1d60: 6e 20 74 68 69 73 20 21 3d 20 26 72 68 73 20 3f  n this != &rhs ?
1d70: 20 63 6f 70 79 28 72 68 73 29 20 3a 20 2a 74 68   copy(rhs) : *th
1d80: 69 73 3b 20 7d 0a 0a 09 2f 2f 2f 20 5c 62 72 69  is; }.../// \bri
1d90: 65 66 20 54 65 73 74 20 77 68 65 74 68 65 72 20  ef Test whether 
1da0: 74 68 65 20 71 75 65 72 79 20 74 68 61 74 20 63  the query that c
1db0: 72 65 61 74 65 64 20 74 68 69 73 20 72 65 73 75  reated this resu
1dc0: 6c 74 20 73 75 63 63 65 65 64 65 64 0a 09 2f 2f  lt succeeded..//
1dd0: 2f 0a 09 2f 2f 2f 20 49 66 20 79 6f 75 20 74 65  /../// If you te
1de0: 73 74 20 74 68 69 73 20 6f 62 6a 65 63 74 20 69  st this object i
1df0: 6e 20 62 6f 6f 6c 20 63 6f 6e 74 65 78 74 20 61  n bool context a
1e00: 6e 64 20 69 74 27 73 20 66 61 6c 73 65 2c 20 69  nd it's false, i
1e10: 74 27 73 20 61 0a 09 2f 2f 2f 20 73 69 67 6e 61  t's a../// signa
1e20: 6c 20 74 68 61 74 20 74 68 65 20 71 75 65 72 79  l that the query
1e30: 20 74 68 69 73 20 77 61 73 20 63 72 65 61 74 65   this was create
1e40: 64 20 66 72 6f 6d 20 66 61 69 6c 65 64 20 69 6e  d from failed in
1e50: 20 73 6f 6d 65 20 77 61 79 2e 0a 09 2f 2f 2f 20   some way.../// 
1e60: 43 61 6c 6c 20 51 75 65 72 79 3a 3a 65 72 72 6f  Call Query::erro
1e70: 72 28 29 20 6f 72 20 51 75 65 72 79 3a 3a 65 72  r() or Query::er
1e80: 72 6e 75 6d 28 29 20 74 6f 20 66 69 6e 64 20 6f  rnum() to find o
1e90: 75 74 20 77 68 61 74 20 65 78 61 63 74 6c 79 0a  ut what exactly.
1ea0: 09 2f 2f 2f 20 68 61 70 70 65 6e 65 64 2e 0a 09  ./// happened...
1eb0: 6f 70 65 72 61 74 6f 72 20 70 72 69 76 61 74 65  operator private
1ec0: 5f 62 6f 6f 6c 5f 74 79 70 65 28 29 20 63 6f 6e  _bool_type() con
1ed0: 73 74 0a 09 7b 0a 09 09 72 65 74 75 72 6e 20 63  st..{...return c
1ee0: 6f 70 61 63 65 74 69 63 5f 20 3f 20 26 53 74 6f  opacetic_ ? &Sto
1ef0: 72 65 51 75 65 72 79 52 65 73 75 6c 74 3a 3a 63  reQueryResult::c
1f00: 6f 70 61 63 65 74 69 63 5f 20 3a 20 30 3b 0a 09  opacetic_ : 0;..
1f10: 7d 0a 0a 70 72 69 76 61 74 65 3a 0a 09 2f 2f 2f  }..private:..///
1f20: 20 5c 62 72 69 65 66 20 43 6f 70 79 20 61 6e 6f   \brief Copy ano
1f30: 74 68 65 72 20 53 74 6f 72 65 51 75 65 72 79 52  ther StoreQueryR
1f40: 65 73 75 6c 74 20 6f 62 6a 65 63 74 27 73 20 63  esult object's c
1f50: 6f 6e 74 65 6e 74 73 20 69 6e 74 6f 20 74 68 69  ontents into thi
1f60: 73 0a 09 2f 2f 2f 20 6f 6e 65 2e 0a 09 53 74 6f  s../// one...Sto
1f70: 72 65 51 75 65 72 79 52 65 73 75 6c 74 26 20 63  reQueryResult& c
1f80: 6f 70 79 28 63 6f 6e 73 74 20 53 74 6f 72 65 51  opy(const StoreQ
1f90: 75 65 72 79 52 65 73 75 6c 74 26 20 6f 74 68 65  ueryResult& othe
1fa0: 72 29 3b 0a 0a 09 62 6f 6f 6c 20 63 6f 70 61 63  r);...bool copac
1fb0: 65 74 69 63 5f 3b 09 2f 2f 2f 3c 20 74 72 75 65  etic_;.///< true
1fc0: 20 69 66 20 69 6e 69 74 69 61 6c 69 7a 65 64 20   if initialized 
1fd0: 66 72 6f 6d 20 61 20 67 6f 6f 64 20 72 65 73 75  from a good resu
1fe0: 6c 74 20 73 65 74 0a 7d 3b 0a 0a 0a 2f 2f 2f 20  lt set.};.../// 
1ff0: 5c 62 72 69 65 66 20 46 75 6e 63 74 6f 72 20 74  \brief Functor t
2000: 6f 20 63 61 6c 6c 20 6d 79 73 71 6c 5f 66 72 65  o call mysql_fre
2010: 65 5f 72 65 73 75 6c 74 28 29 20 6f 6e 20 74 68  e_result() on th
2020: 65 20 70 6f 69 6e 74 65 72 20 79 6f 75 20 70 61  e pointer you pa
2030: 73 73 0a 2f 2f 2f 20 74 6f 20 69 74 2e 0a 2f 2f  ss./// to it..//
2040: 2f 0a 2f 2f 2f 20 54 68 69 73 20 6f 76 65 72 72  /./// This overr
2050: 69 64 65 73 20 52 65 66 43 6f 75 6e 74 65 64 50  ides RefCountedP
2060: 6f 69 6e 74 65 72 27 73 20 64 65 66 61 75 6c 74  ointer's default
2070: 20 64 65 73 74 72 6f 79 65 72 2c 20 77 68 69 63   destroyer, whic
2080: 68 20 75 73 65 73 0a 2f 2f 2f 20 6f 70 65 72 61  h uses./// opera
2090: 74 6f 72 20 64 65 6c 65 74 65 3b 20 69 74 20 61  tor delete; it a
20a0: 6e 6e 6f 79 73 20 74 68 65 20 43 20 41 50 49 20  nnoys the C API 
20b0: 77 68 65 6e 20 79 6f 75 20 6e 75 6b 65 20 69 74  when you nuke it
20c0: 73 20 64 61 74 61 0a 2f 2f 2f 20 73 74 72 75 63  s data./// struc
20d0: 74 75 72 65 73 20 74 68 69 73 20 77 61 79 2e 20  tures this way. 
20e0: 3a 29 0a 74 65 6d 70 6c 61 74 65 20 3c 3e 0a 73  :).template <>.s
20f0: 74 72 75 63 74 20 52 65 66 43 6f 75 6e 74 65 64  truct RefCounted
2100: 50 6f 69 6e 74 65 72 44 65 73 74 72 6f 79 65 72  PointerDestroyer
2110: 3c 4d 59 53 51 4c 5f 52 45 53 3e 0a 7b 0a 09 2f  <MYSQL_RES>.{../
2120: 2f 2f 20 5c 62 72 69 65 66 20 46 75 6e 63 74 6f  // \brief Functo
2130: 72 20 69 6d 70 6c 65 6d 65 6e 74 61 74 69 6f 6e  r implementation
2140: 0a 09 76 6f 69 64 20 6f 70 65 72 61 74 6f 72 28  ..void operator(
2150: 29 28 4d 59 53 51 4c 5f 52 45 53 2a 20 64 6f 6f  )(MYSQL_RES* doo
2160: 6d 65 64 29 20 63 6f 6e 73 74 0a 09 7b 0a 09 09  med) const..{...
2170: 69 66 20 28 64 6f 6f 6d 65 64 29 20 7b 0a 09 09  if (doomed) {...
2180: 09 6d 79 73 71 6c 5f 66 72 65 65 5f 72 65 73 75  .mysql_free_resu
2190: 6c 74 28 64 6f 6f 6d 65 64 29 3b 0a 09 09 7d 0a  lt(doomed);...}.
21a0: 09 7d 0a 7d 3b 0a 0a 0a 2f 2f 2f 20 5c 62 72 69  .}.};.../// \bri
21b0: 65 66 20 53 74 6f 72 65 51 75 65 72 79 52 65 73  ef StoreQueryRes
21c0: 75 6c 74 20 73 65 74 20 74 79 70 65 20 66 6f 72  ult set type for
21d0: 20 22 75 73 65 22 20 71 75 65 72 69 65 73 0a 2f   "use" queries./
21e0: 2f 2f 0a 2f 2f 2f 20 53 65 65 20 74 68 65 20 75  //./// See the u
21f0: 73 65 72 20 6d 61 6e 75 61 6c 20 66 6f 72 20 74  ser manual for t
2200: 68 65 20 72 65 61 73 6f 6e 20 79 6f 75 20 6d 69  he reason you mi
2210: 67 68 74 20 77 61 6e 74 20 74 6f 20 75 73 65 20  ght want to use 
2220: 74 68 69 73 20 65 76 65 6e 0a 2f 2f 2f 20 74 68  this even./// th
2230: 6f 75 67 68 20 69 74 73 20 69 6e 74 65 72 66 61  ough its interfa
2240: 63 65 20 69 73 20 6c 65 73 73 20 66 72 69 65 6e  ce is less frien
2250: 64 6c 79 20 74 68 61 6e 20 53 74 6f 72 65 51 75  dly than StoreQu
2260: 65 72 79 52 65 73 75 6c 74 27 73 2e 0a 0a 63 6c  eryResult's...cl
2270: 61 73 73 20 4d 59 53 51 4c 50 50 5f 45 58 50 4f  ass MYSQLPP_EXPO
2280: 52 54 20 55 73 65 51 75 65 72 79 52 65 73 75 6c  RT UseQueryResul
2290: 74 20 3a 20 70 75 62 6c 69 63 20 52 65 73 75 6c  t : public Resul
22a0: 74 42 61 73 65 0a 7b 0a 70 75 62 6c 69 63 3a 0a  tBase.{.public:.
22b0: 09 2f 2f 2f 20 5c 62 72 69 65 66 20 44 65 66 61  ./// \brief Defa
22c0: 75 6c 74 20 63 6f 6e 73 74 72 75 63 74 6f 72 0a  ult constructor.
22d0: 09 55 73 65 51 75 65 72 79 52 65 73 75 6c 74 28  .UseQueryResult(
22e0: 29 20 3a 0a 09 52 65 73 75 6c 74 42 61 73 65 28  ) :..ResultBase(
22f0: 29 0a 09 7b 0a 09 7d 0a 09 0a 09 2f 2f 2f 20 5c  )..{..}..../// \
2300: 62 72 69 65 66 20 43 72 65 61 74 65 20 74 68 65  brief Create the
2310: 20 6f 62 6a 65 63 74 2c 20 66 75 6c 6c 79 20 69   object, fully i
2320: 6e 69 74 69 61 6c 69 7a 65 64 0a 09 55 73 65 51  nitialized..UseQ
2330: 75 65 72 79 52 65 73 75 6c 74 28 4d 59 53 51 4c  ueryResult(MYSQL
2340: 5f 52 45 53 2a 20 72 65 73 75 6c 74 2c 20 44 42  _RES* result, DB
2350: 44 72 69 76 65 72 2a 20 64 62 64 2c 20 62 6f 6f  Driver* dbd, boo
2360: 6c 20 74 65 20 3d 20 74 72 75 65 29 3b 0a 09 0a  l te = true);...
2370: 09 2f 2f 2f 20 5c 62 72 69 65 66 20 43 72 65 61  ./// \brief Crea
2380: 74 65 20 61 20 63 6f 70 79 20 6f 66 20 61 6e 6f  te a copy of ano
2390: 74 68 65 72 20 55 73 65 51 75 65 72 79 52 65 73  ther UseQueryRes
23a0: 75 6c 74 20 6f 62 6a 65 63 74 0a 09 55 73 65 51  ult object..UseQ
23b0: 75 65 72 79 52 65 73 75 6c 74 28 63 6f 6e 73 74  ueryResult(const
23c0: 20 55 73 65 51 75 65 72 79 52 65 73 75 6c 74 26   UseQueryResult&
23d0: 20 6f 74 68 65 72 29 20 3a 0a 09 52 65 73 75 6c   other) :..Resul
23e0: 74 42 61 73 65 28 29 0a 09 7b 0a 09 09 63 6f 70  tBase()..{...cop
23f0: 79 28 6f 74 68 65 72 29 3b 0a 09 7d 0a 09 0a 09  y(other);..}....
2400: 2f 2f 2f 20 5c 62 72 69 65 66 20 44 65 73 74 72  /// \brief Destr
2410: 6f 79 20 6f 62 6a 65 63 74 0a 09 7e 55 73 65 51  oy object..~UseQ
2420: 75 65 72 79 52 65 73 75 6c 74 28 29 20 7b 20 7d  ueryResult() { }
2430: 0a 0a 09 2f 2f 2f 20 5c 62 72 69 65 66 20 43 6f  .../// \brief Co
2440: 70 79 20 61 6e 6f 74 68 65 72 20 55 73 65 51 75  py another UseQu
2450: 65 72 79 52 65 73 75 6c 74 20 6f 62 6a 65 63 74  eryResult object
2460: 27 73 20 64 61 74 61 20 69 6e 74 6f 20 74 68 69  's data into thi
2470: 73 20 6f 62 6a 65 63 74 0a 09 55 73 65 51 75 65  s object..UseQue
2480: 72 79 52 65 73 75 6c 74 26 20 6f 70 65 72 61 74  ryResult& operat
2490: 6f 72 20 3d 28 63 6f 6e 73 74 20 55 73 65 51 75  or =(const UseQu
24a0: 65 72 79 52 65 73 75 6c 74 26 20 72 68 73 29 0a  eryResult& rhs).
24b0: 09 09 09 7b 20 72 65 74 75 72 6e 20 74 68 69 73  ...{ return this
24c0: 20 21 3d 20 26 72 68 73 20 3f 20 63 6f 70 79 28   != &rhs ? copy(
24d0: 72 68 73 29 20 3a 20 2a 74 68 69 73 3b 20 7d 0a  rhs) : *this; }.
24e0: 0a 09 2f 2f 2f 20 5c 62 72 69 65 66 20 52 65 74  ../// \brief Ret
24f0: 75 72 6e 73 20 74 68 65 20 6e 65 78 74 20 66 69  urns the next fi
2500: 65 6c 64 20 69 6e 20 74 68 69 73 20 72 65 73 75  eld in this resu
2510: 6c 74 20 73 65 74 0a 09 63 6f 6e 73 74 20 46 69  lt set..const Fi
2520: 65 6c 64 26 20 66 65 74 63 68 5f 66 69 65 6c 64  eld& fetch_field
2530: 28 29 20 63 6f 6e 73 74 0a 09 09 09 7b 20 72 65  () const....{ re
2540: 74 75 72 6e 20 66 69 65 6c 64 73 5f 2e 61 74 28  turn fields_.at(
2550: 63 75 72 72 65 6e 74 5f 66 69 65 6c 64 5f 2b 2b  current_field_++
2560: 29 3b 20 7d 0a 0a 09 2f 2f 2f 20 5c 62 72 69 65  ); }.../// \brie
2570: 66 20 52 65 74 75 72 6e 73 20 74 68 65 20 67 69  f Returns the gi
2580: 76 65 6e 20 66 69 65 6c 64 20 69 6e 20 74 68 69  ven field in thi
2590: 73 20 72 65 73 75 6c 74 20 73 65 74 0a 09 63 6f  s result set..co
25a0: 6e 73 74 20 46 69 65 6c 64 26 20 66 65 74 63 68  nst Field& fetch
25b0: 5f 66 69 65 6c 64 28 46 69 65 6c 64 73 3a 3a 73  _field(Fields::s
25c0: 69 7a 65 5f 74 79 70 65 20 69 29 20 63 6f 6e 73  ize_type i) cons
25d0: 74 0a 09 09 09 7b 20 72 65 74 75 72 6e 20 66 69  t....{ return fi
25e0: 65 6c 64 73 5f 2e 61 74 28 69 29 3b 20 7d 0a 0a  elds_.at(i); }..
25f0: 09 2f 2f 2f 20 5c 62 72 69 65 66 20 52 65 74 75  ./// \brief Retu
2600: 72 6e 73 20 74 68 65 20 6c 65 6e 67 74 68 73 20  rns the lengths 
2610: 6f 66 20 74 68 65 20 66 69 65 6c 64 73 20 69 6e  of the fields in
2620: 20 74 68 65 20 63 75 72 72 65 6e 74 20 72 6f 77   the current row
2630: 20 6f 66 0a 09 2f 2f 2f 20 74 68 65 20 72 65 73   of../// the res
2640: 75 6c 74 20 73 65 74 2e 0a 09 2f 2f 2f 0a 09 2f  ult set...///../
2650: 2f 2f 20 5c 69 6e 74 65 72 6e 61 6c 20 54 68 69  // \internal Thi
2660: 73 20 73 68 6f 75 6c 64 20 6e 6f 74 20 62 65 20  s should not be 
2670: 74 65 72 72 69 62 6c 79 20 75 73 65 66 75 6c 20  terribly useful 
2680: 74 6f 20 65 6e 64 2d 75 73 65 72 20 63 6f 64 65  to end-user code
2690: 2e 0a 09 2f 2f 2f 20 54 68 65 20 52 6f 77 20 6f  .../// The Row o
26a0: 62 6a 65 63 74 20 72 65 74 75 72 6e 65 64 20 62  bject returned b
26b0: 79 20 66 65 74 63 68 5f 72 6f 77 28 29 20 63 6f  y fetch_row() co
26c0: 6e 74 61 69 6e 73 20 74 68 65 73 65 20 6c 65 6e  ntains these len
26d0: 67 74 68 73 2e 0a 09 63 6f 6e 73 74 20 75 6e 73  gths...const uns
26e0: 69 67 6e 65 64 20 6c 6f 6e 67 2a 20 66 65 74 63  igned long* fetc
26f0: 68 5f 6c 65 6e 67 74 68 73 28 29 20 63 6f 6e 73  h_lengths() cons
2700: 74 3b 0a 0a 09 2f 2f 2f 20 5c 62 72 69 65 66 20  t;.../// \brief 
2710: 52 65 74 75 72 6e 73 20 74 68 65 20 6e 65 78 74  Returns the next
2720: 20 72 6f 77 20 69 6e 20 61 20 22 75 73 65 22 20   row in a "use" 
2730: 71 75 65 72 79 27 73 20 72 65 73 75 6c 74 20 73  query's result s
2740: 65 74 0a 09 2f 2f 2f 0a 09 2f 2f 2f 20 54 68 69  et..///../// Thi
2750: 73 20 69 73 20 61 20 74 68 69 63 6b 20 77 72 61  s is a thick wra
2760: 70 70 65 72 20 61 72 6f 75 6e 64 20 44 42 44 72  pper around DBDr
2770: 69 76 65 72 3a 3a 66 65 74 63 68 5f 72 6f 77 28  iver::fetch_row(
2780: 29 2e 20 20 49 74 20 64 6f 65 73 20 61 0a 09 2f  ).  It does a../
2790: 2f 2f 20 6c 6f 74 20 6f 66 20 65 72 72 6f 72 20  // lot of error 
27a0: 63 68 65 63 6b 69 6e 67 20 62 65 66 6f 72 65 20  checking before 
27b0: 72 65 74 75 72 6e 69 6e 67 20 74 68 65 20 52 6f  returning the Ro
27c0: 77 20 6f 62 6a 65 63 74 20 63 6f 6e 74 61 69 6e  w object contain
27d0: 69 6e 67 0a 09 2f 2f 2f 20 74 68 65 20 72 6f 77  ing../// the row
27e0: 20 64 61 74 61 2e 0a 09 2f 2f 2f 0a 09 2f 2f 2f   data...///..///
27f0: 20 5c 73 61 20 66 65 74 63 68 5f 72 61 77 5f 72   \sa fetch_raw_r
2800: 6f 77 28 29 0a 09 52 6f 77 20 66 65 74 63 68 5f  ow()..Row fetch_
2810: 72 6f 77 28 29 20 63 6f 6e 73 74 3b 0a 0a 09 2f  row() const;.../
2820: 2f 2f 20 5c 62 72 69 65 66 20 57 72 61 70 73 20  // \brief Wraps 
2830: 6d 79 73 71 6c 5f 66 65 74 63 68 5f 72 6f 77 28  mysql_fetch_row(
2840: 29 20 69 6e 20 4d 79 53 51 4c 20 43 20 41 50 49  ) in MySQL C API
2850: 2e 0a 09 2f 2f 2f 0a 09 2f 2f 2f 20 5c 69 6e 74  ...///../// \int
2860: 65 72 6e 61 6c 20 59 6f 75 20 61 6c 6d 6f 73 74  ernal You almost
2870: 20 63 65 72 74 61 69 6e 6c 79 20 77 61 6e 74 20   certainly want 
2880: 74 6f 20 63 61 6c 6c 20 66 65 74 63 68 5f 72 6f  to call fetch_ro
2890: 77 28 29 20 69 6e 73 74 65 61 64 2e 0a 09 2f 2f  w() instead...//
28a0: 2f 20 49 74 20 69 73 20 61 6e 74 69 63 69 70 61  / It is anticipa
28b0: 74 65 64 20 74 68 61 74 20 74 68 69 73 20 69 73  ted that this is
28c0: 20 6f 6e 6c 79 20 75 73 65 66 75 6c 20 77 69 74   only useful wit
28d0: 68 69 6e 20 74 68 65 20 6c 69 62 72 61 72 79 2c  hin the library,
28e0: 0a 09 2f 2f 2f 20 74 6f 20 69 6d 70 6c 65 6d 65  ../// to impleme
28f0: 6e 74 20 68 69 67 68 65 72 2d 6c 65 76 65 6c 20  nt higher-level 
2900: 71 75 65 72 79 20 74 79 70 65 73 20 6f 6e 20 74  query types on t
2910: 6f 70 20 6f 66 20 72 61 77 20 22 75 73 65 22 0a  op of raw "use".
2920: 09 2f 2f 2f 20 71 75 65 72 69 65 73 2e 20 51 75  ./// queries. Qu
2930: 65 72 79 3a 3a 73 74 6f 72 65 69 6e 28 29 20 75  ery::storein() u
2940: 73 65 73 20 69 74 2c 20 66 6f 72 20 65 78 61 6d  ses it, for exam
2950: 70 6c 65 2e 0a 09 4d 59 53 51 4c 5f 52 4f 57 20  ple...MYSQL_ROW 
2960: 66 65 74 63 68 5f 72 61 77 5f 72 6f 77 28 29 20  fetch_raw_row() 
2970: 63 6f 6e 73 74 3b 0a 0a 09 2f 2f 2f 20 5c 62 72  const;.../// \br
2980: 69 65 66 20 4a 75 6d 70 73 20 74 6f 20 74 68 65  ief Jumps to the
2990: 20 67 69 76 65 6e 20 66 69 65 6c 64 20 77 69 74   given field wit
29a0: 68 69 6e 20 74 68 65 20 72 65 73 75 6c 74 20 73  hin the result s
29b0: 65 74 0a 09 2f 2f 2f 0a 09 2f 2f 2f 20 43 61 6c  et..///../// Cal
29c0: 6c 69 6e 67 20 74 68 69 73 20 61 6c 6c 6f 77 73  ling this allows
29d0: 20 79 6f 75 20 74 6f 20 72 65 73 65 74 20 74 68   you to reset th
29e0: 65 20 64 65 66 61 75 6c 74 20 66 69 65 6c 64 20  e default field 
29f0: 69 6e 64 65 78 20 75 73 65 64 0a 09 2f 2f 2f 20  index used../// 
2a00: 62 79 20 66 65 74 63 68 5f 66 69 65 6c 64 28 29  by fetch_field()
2a10: 2e 0a 09 76 6f 69 64 20 66 69 65 6c 64 5f 73 65  ...void field_se
2a20: 65 6b 28 46 69 65 6c 64 73 3a 3a 73 69 7a 65 5f  ek(Fields::size_
2a30: 74 79 70 65 20 66 69 65 6c 64 29 20 63 6f 6e 73  type field) cons
2a40: 74 0a 09 09 09 7b 20 63 75 72 72 65 6e 74 5f 66  t....{ current_f
2a50: 69 65 6c 64 5f 20 3d 20 66 69 65 6c 64 3b 20 7d  ield_ = field; }
2a60: 0a 0a 09 2f 2f 2f 20 5c 62 72 69 65 66 20 52 65  .../// \brief Re
2a70: 74 75 72 6e 20 74 68 65 20 70 6f 69 6e 74 65 72  turn the pointer
2a80: 20 74 6f 20 74 68 65 20 75 6e 64 65 72 6c 79 69   to the underlyi
2a90: 6e 67 20 4d 79 53 51 4c 20 43 20 41 50 49 0a 09  ng MySQL C API..
2aa0: 2f 2f 2f 20 72 65 73 75 6c 74 20 73 65 74 20 6f  /// result set o
2ab0: 62 6a 65 63 74 2e 0a 09 2f 2f 2f 0a 09 2f 2f 2f  bject...///..///
2ac0: 20 57 68 69 6c 65 20 74 68 69 73 20 68 61 73 20   While this has 
2ad0: 6f 62 76 69 6f 75 73 20 69 6e 68 65 72 65 6e 74  obvious inherent
2ae0: 20 76 61 6c 75 65 20 66 6f 72 20 74 68 6f 73 65   value for those
2af0: 20 74 69 6d 65 73 20 79 6f 75 20 6e 65 65 64 0a   times you need.
2b00: 09 2f 2f 2f 20 74 6f 20 64 69 67 20 62 65 6e 65  ./// to dig bene
2b10: 61 74 68 20 74 68 65 20 4d 79 53 51 4c 2b 2b 20  ath the MySQL++ 
2b20: 69 6e 74 65 72 66 61 63 65 2c 20 69 74 20 68 61  interface, it ha
2b30: 73 20 73 75 62 74 6c 65 72 20 76 61 6c 75 65 2e  s subtler value.
2b40: 0a 09 2f 2f 2f 20 49 74 20 65 66 66 65 63 74 69  ../// It effecti
2b50: 76 65 6c 79 20 73 74 61 6e 64 73 20 69 6e 20 66  vely stands in f
2b60: 6f 72 20 6f 70 65 72 61 74 6f 72 20 62 6f 6f 6c  or operator bool
2b70: 28 29 2c 20 6f 70 65 72 61 74 6f 72 20 21 28 29  (), operator !()
2b80: 2c 0a 09 2f 2f 2f 20 6f 70 65 72 61 74 6f 72 20  ,../// operator 
2b90: 3d 3d 28 29 2c 20 61 6e 64 20 6f 70 65 72 61 74  ==(), and operat
2ba0: 6f 72 20 21 3d 28 29 2c 20 62 65 63 61 75 73 65  or !=(), because
2bb0: 20 74 68 65 20 43 2b 2b 20 63 6f 6d 70 69 6c 65   the C++ compile
2bc0: 72 20 63 61 6e 0a 09 2f 2f 2f 20 69 6d 70 6c 65  r can../// imple
2bd0: 6d 65 6e 74 20 61 6c 6c 20 6f 66 20 74 68 65 73  ment all of thes
2be0: 65 20 77 69 74 68 20 61 20 4d 59 53 51 4c 5f 52  e with a MYSQL_R
2bf0: 45 53 2a 2e 0a 09 2f 2f 2f 0a 09 2f 2f 2f 20 4f  ES*...///../// O
2c00: 66 20 74 68 65 73 65 20 75 73 65 73 2c 20 74 68  f these uses, th
2c10: 65 20 6d 6f 73 74 20 76 61 6c 75 61 62 6c 65 20  e most valuable 
2c20: 69 73 20 75 73 69 6e 67 20 74 68 65 20 55 73 65  is using the Use
2c30: 51 75 65 72 79 52 65 73 75 6c 74 0a 09 2f 2f 2f  QueryResult..///
2c40: 20 6f 62 6a 65 63 74 20 69 6e 20 62 6f 6f 6c 20   object in bool 
2c50: 63 6f 6e 74 65 78 74 20 74 6f 20 64 65 74 65 72  context to deter
2c60: 6d 69 6e 65 20 69 66 20 74 68 65 20 71 75 65 72  mine if the quer
2c70: 79 20 74 68 61 74 20 63 72 65 61 74 65 64 0a 09  y that created..
2c80: 2f 2f 20 69 74 20 77 61 73 20 73 75 63 63 65 73  // it was succes
2c90: 73 66 75 6c 3a 0a 09 2f 2f 2f 0a 09 2f 2f 2f 20  sful:..///../// 
2ca0: 5c 63 6f 64 65 0a 09 2f 2f 2f 20 20 20 51 75 65  \code..///   Que
2cb0: 72 79 20 71 28 22 2e 2e 2e 2e 22 29 3b 0a 09 2f  ry q("....");../
2cc0: 2f 2f 20 20 20 69 66 20 28 55 73 65 51 75 65 72  //   if (UseQuer
2cd0: 79 52 65 73 75 6c 74 20 72 65 73 20 3d 20 71 2e  yResult res = q.
2ce0: 75 73 65 28 29 29 20 7b 0a 09 2f 2f 2f 20 20 20  use()) {..///   
2cf0: 20 20 20 20 2f 2f 20 43 61 6e 20 75 73 65 20 27      // Can use '
2d00: 72 65 73 27 2c 20 71 75 65 72 79 20 73 75 63 63  res', query succ
2d10: 65 65 64 65 64 0a 09 2f 2f 2f 20 20 20 7d 0a 09  eeded..///   }..
2d20: 2f 2f 2f 20 20 20 65 6c 73 65 20 7b 0a 09 2f 2f  ///   else {..//
2d30: 2f 20 20 20 20 20 20 20 2f 2f 20 51 75 65 72 79  /       // Query
2d40: 20 66 61 69 6c 65 64 2c 20 63 61 6c 6c 20 51 75   failed, call Qu
2d50: 65 72 79 3a 3a 65 72 72 6f 72 28 29 20 6f 72 20  ery::error() or 
2d60: 3a 3a 65 72 72 6e 75 6d 28 29 20 66 6f 72 20 77  ::errnum() for w
2d70: 68 79 0a 09 2f 2f 2f 20 20 20 7d 0a 09 2f 2f 2f  hy..///   }..///
2d80: 20 5c 65 6e 64 63 6f 64 65 0a 09 6f 70 65 72 61   \endcode..opera
2d90: 74 6f 72 20 4d 59 53 51 4c 5f 52 45 53 2a 28 29  tor MYSQL_RES*()
2da0: 20 63 6f 6e 73 74 20 7b 20 72 65 74 75 72 6e 20   const { return 
2db0: 72 65 73 75 6c 74 5f 2e 72 61 77 28 29 3b 20 7d  result_.raw(); }
2dc0: 0a 09 0a 70 72 69 76 61 74 65 3a 0a 09 2f 2f 2f  ...private:..///
2dd0: 20 5c 62 72 69 65 66 20 43 6f 70 79 20 61 6e 6f   \brief Copy ano
2de0: 74 68 65 72 20 52 65 73 75 6c 74 42 61 73 65 20  ther ResultBase 
2df0: 6f 62 6a 65 63 74 27 73 20 63 6f 6e 74 65 6e 74  object's content
2e00: 73 20 69 6e 74 6f 20 74 68 69 73 20 6f 6e 65 2e  s into this one.
2e10: 0a 09 55 73 65 51 75 65 72 79 52 65 73 75 6c 74  ..UseQueryResult
2e20: 26 20 63 6f 70 79 28 63 6f 6e 73 74 20 55 73 65  & copy(const Use
2e30: 51 75 65 72 79 52 65 73 75 6c 74 26 20 6f 74 68  QueryResult& oth
2e40: 65 72 29 3b 0a 0a 09 2f 2f 2f 20 5c 62 72 69 65  er);.../// \brie
2e50: 66 20 52 65 66 65 72 65 6e 63 65 20 74 6f 20 75  f Reference to u
2e60: 6e 64 65 72 6c 79 69 6e 67 20 43 20 41 50 49 20  nderlying C API 
2e70: 72 65 73 75 6c 74 20 73 65 74 0a 09 2f 2f 2f 0a  result set..///.
2e80: 09 2f 2f 2f 20 54 68 69 73 20 69 73 20 6d 75 74  ./// This is mut
2e90: 61 62 6c 65 20 62 65 63 61 75 73 65 20 73 6f 20  able because so 
2ea0: 6d 61 6e 79 20 6d 65 74 68 6f 64 73 20 69 6e 20  many methods in 
2eb0: 74 68 69 73 20 63 6c 61 73 73 20 61 72 65 0a 09  this class are..
2ec0: 2f 2f 2f 20 61 72 65 20 6a 75 73 74 69 66 69 61  /// are justifia
2ed0: 62 6c 79 20 63 6f 6e 73 74 20 62 65 63 61 75 73  bly const becaus
2ee0: 65 20 74 68 65 79 20 64 6f 6e 27 74 20 6d 6f 64  e they don't mod
2ef0: 69 66 79 20 74 68 65 20 72 65 73 75 6c 74 0a 09  ify the result..
2f00: 2f 2f 2f 20 73 65 74 27 73 20 22 76 61 6c 75 65  /// set's "value
2f10: 22 20 62 75 74 20 74 68 65 79 20 63 61 6c 6c 20  " but they call 
2f20: 43 20 41 50 49 20 6d 65 74 68 6f 64 73 20 74 68  C API methods th
2f30: 61 74 20 74 61 6b 65 20 6e 6f 6e 2d 63 6f 6e 73  at take non-cons
2f40: 74 0a 09 2f 2f 2f 20 4d 59 53 51 4c 5f 52 45 53  t../// MYSQL_RES
2f50: 2a 20 73 6f 20 74 68 65 79 20 63 61 6e 20 6f 6e  * so they can on
2f60: 6c 79 20 62 65 20 63 6f 6e 73 74 20 69 66 20 74  ly be const if t
2f70: 68 69 73 20 69 73 20 6d 75 74 61 62 6c 65 2e 20  his is mutable. 
2f80: 20 49 74 27 73 0a 09 2f 2f 2f 20 71 75 69 74 65   It's../// quite
2f90: 20 6c 69 6b 65 6c 79 20 74 68 61 74 20 74 68 65   likely that the
2fa0: 73 65 20 41 50 49 20 66 75 6e 63 74 69 6f 6e 73  se API functions
2fb0: 20 64 6f 20 6d 6f 64 69 66 79 20 74 68 65 20 4d   do modify the M
2fc0: 59 53 51 4c 5f 52 45 53 0a 09 2f 2f 2f 20 6f 62  YSQL_RES../// ob
2fd0: 6a 65 63 74 2c 20 73 6f 20 73 74 72 69 63 74 20  ject, so strict 
2fe0: 63 6f 6e 73 74 6e 65 73 73 20 73 61 79 73 20 74  constness says t
2ff0: 68 69 73 20 6f 62 6a 65 63 74 20 63 68 61 6e 67  his object chang
3000: 65 64 2c 20 74 6f 6f 2c 20 62 75 74 0a 09 2f 2f  ed, too, but..//
3010: 2f 20 74 68 69 73 20 68 61 73 20 61 6c 77 61 79  / this has alway
3020: 73 20 62 65 65 6e 20 6d 75 74 61 62 6c 65 20 61  s been mutable a
3030: 6e 64 20 74 68 65 20 72 65 73 75 6c 74 69 6e 67  nd the resulting
3040: 20 62 65 68 61 76 69 6f 72 20 68 61 73 6e 27 74   behavior hasn't
3050: 20 0a 09 2f 2f 2f 20 63 6f 6e 66 75 73 65 64 20   ../// confused 
3060: 61 6e 79 6f 6e 65 20 79 65 74 2e 0a 09 6d 75 74  anyone yet...mut
3070: 61 62 6c 65 20 52 65 66 43 6f 75 6e 74 65 64 50  able RefCountedP
3080: 6f 69 6e 74 65 72 3c 4d 59 53 51 4c 5f 52 45 53  ointer<MYSQL_RES
3090: 3e 20 72 65 73 75 6c 74 5f 3b 0a 7d 3b 0a 0a 0a  > result_;.};...
30a0: 2f 2f 2f 20 5c 62 72 69 65 66 20 53 77 61 70 73  /// \brief Swaps
30b0: 20 74 77 6f 20 53 74 6f 72 65 51 75 65 72 79 52   two StoreQueryR
30c0: 65 73 75 6c 74 20 6f 62 6a 65 63 74 73 0a 69 6e  esult objects.in
30d0: 6c 69 6e 65 20 76 6f 69 64 0a 73 77 61 70 28 53  line void.swap(S
30e0: 74 6f 72 65 51 75 65 72 79 52 65 73 75 6c 74 26  toreQueryResult&
30f0: 20 78 2c 20 53 74 6f 72 65 51 75 65 72 79 52 65   x, StoreQueryRe
3100: 73 75 6c 74 26 20 79 29 0a 7b 0a 09 53 74 6f 72  sult& y).{..Stor
3110: 65 51 75 65 72 79 52 65 73 75 6c 74 20 74 6d 70  eQueryResult tmp
3120: 20 3d 20 78 3b 0a 09 78 20 3d 20 79 3b 0a 09 79   = x;..x = y;..y
3130: 20 3d 20 74 6d 70 3b 0a 7d 0a 0a 2f 2f 2f 20 5c   = tmp;.}../// \
3140: 62 72 69 65 66 20 53 77 61 70 73 20 74 77 6f 20  brief Swaps two 
3150: 55 73 65 51 75 65 72 79 52 65 73 75 6c 74 20 6f  UseQueryResult o
3160: 62 6a 65 63 74 73 0a 69 6e 6c 69 6e 65 20 76 6f  bjects.inline vo
3170: 69 64 0a 73 77 61 70 28 55 73 65 51 75 65 72 79  id.swap(UseQuery
3180: 52 65 73 75 6c 74 26 20 78 2c 20 55 73 65 51 75  Result& x, UseQu
3190: 65 72 79 52 65 73 75 6c 74 26 20 79 29 0a 7b 0a  eryResult& y).{.
31a0: 09 55 73 65 51 75 65 72 79 52 65 73 75 6c 74 20  .UseQueryResult 
31b0: 74 6d 70 20 3d 20 78 3b 0a 09 78 20 3d 20 79 3b  tmp = x;..x = y;
31c0: 0a 09 79 20 3d 20 74 6d 70 3b 0a 7d 0a 0a 7d 20  ..y = tmp;.}..} 
31d0: 2f 2f 20 65 6e 64 20 6e 61 6d 65 73 70 61 63 65  // end namespace
31e0: 20 6d 79 73 71 6c 70 70 0a 0a 23 65 6e 64 69 66   mysqlpp..#endif
31f0: 20 2f 2f 20 21 64 65 66 69 6e 65 64 28 4d 59 53   // !defined(MYS
3200: 51 4c 50 50 5f 52 45 53 55 4c 54 5f 48 29 0a     QLPP_RESULT_H).