blob: 9c9631dbabdb678fc6c1939a591b75d2d2dbaf42 [file] [log] [blame]
Tang Cheng37650ea2014-10-20 16:14:41 +08001/* Copyright (c) 2000, 2009, Oracle and/or its affiliates.
2All rights reserved. */
3
4/*
5 NAME
6 occiData.h - header file for OCCI data classes
7
8 DESCRIPTION
9 Class definitions for Stream, Blob, Clob ,Bfile,
10 Number, Date, IntervalYM, IntervalDS, Time,
11 Timestamp
12
13 RELATED DOCUMENTS
14 <note any documents related to this facility>
15
16 EXPORT FUNCTION(S)
17 <external functions declared for use outside package -
18 one-line descriptions>
19
20 INTERNAL FUNCTION(S)
21 <other external functions declared - one-line descriptions>
22
23 EXAMPLES
24
25 NOTES
26 <other useful comments, qualifications, etc.>
27
28 MODIFIED (MM/DD/YY)
29 kkverma 11/23/09 - Replace OCIEnv* type ocienv member to Environment type
30 slynn 03/18/08 - Add get/setContentType.
31 slynn 09/14/06 - Remove string.clear()
32 slynn 07/28/06 - Migrate to new 11g LOB terminology
33 slynn 06/21/06 - Add LobRegion
34 slynn 05/25/06 - New NG Lob Functionality.
35 cparampa 09/06/04 - Date changes
36 shiyer 10/31/03 - Timestamp constructors issue
37 rvallam 10/07/03 - bug 3089939 - add private method in Date to compute
38 hour and min component in daysBetween to be passed
39 to set method of IntervalDS.
40 cparampa 08/21/03 - added toCopy to IntervalDS and IntervalYM
41 cparampa 07/14/03 - make SubscriptionImpl friend of Bytes class.
42 rvallam 02/12/03 - modified BFloat/BDouble interface - BFloat/BDouble
43 type is now a struct
44 cparampa 01/20/03 - made ProducerImpl friend of Bytes class
45 rvallam 11/19/02 - objects support for interval class
46 shiyer 11/15/02 - Add UTF16 support to IntervalYM & IntervalDS
47 cparampa 12/11/02 - removed references to class Payload
48 cparampa 10/12/02 - AQ additions
49 shiyer 10/12/02 - Added UTF16 version of get/set CharsetId in Clob
50 shiyer 09/06/02 - OCCI globalization support
51 aahluwal 06/04/02 - bug 2360115
52 vvinay 02/21/02 - operator= added for Bytes
53 gayyappa 10/23/01 - fix bug 2073327 , use string instead of
54 enum CharSet
55 vvinay 12/21/01 - signed char constructor and cast operator
56 (bug 2073334)
57 binary operator methods not friends any more
58 gayyappa 15/10/01 - add parameter toCopy to Lob/Timestamp private
59 constructors
60 rvallam 04/09/01 - change private constructor in Number to pass
61 parameter by reference and made it const
62 chliang 03/05/01 - disable olint
63 rvallam 01/27/02 - remove #include <ostream>
64 gayyappa 01/17/01 - add methods/operators to Interval and
65 timestamp classes..
66 gayyappa 12/15/00 - interface changes in set methods
67 rvallam 11/29/00 - change method signature in Bytes
68 added 3 new methods in Number
69 rvallam 10/20/00 - change method signatures in Date
70 rvallam 09/15/00 - make StmtImpl/ResultSetImpl friend to
71 interval classes
72 gayyappa 08/21/00 - modified timestamp, interval headers.
73 add OCIEnv to constructor of Bytes.,
74 removed getOCIRaw from Bytes.
75 add const to setVector mthds of anydata.
76 add void* data member to Timestamp/Interval.
77 rvallam 08/10/00 - modified CORE class headers to add friends ,
78 added private constructor in Bytes
79 slari 08/02/00 - comment out Stream
80 rratnam 08/04/00 - updated the LOB stream interface
81 rkasamse 08/07/00 - make getVector friend of Time
82 slari 07/31/00 - add const to Bytes methods
83 slari 07/25/00 - disable Bytes(Bytes *)
84 slari 07/23/00 - add Bytes
85 gayyappa 07/26/00 - update Timestamp, IntervalYM, IntervalDS.
86 gayyappa 07/04/00 - for fixing a problem in occiNumber
87 rratnam 06/13/00 - Updated LOB class headers
88 kmohan 05/31/00 - Change Environment to Environment * in
89 Date constructor
90 kmohan 05/29/00 - No string
91 rkasamse 04/25/00 - Added string class header
92 etucker 04/19/00 - Added CORE class headers
93 kmohan 04/11/00 - Creation
94
95*/
96
97#ifndef _olint /* disable olint check */
98
99#ifndef OCCIDATA_ORACLE
100# define OCCIDATA_ORACLE
101
102#ifndef OCCICOMMON_ORACLE
103#include <occiCommon.h>
104#endif
105
106#ifndef OCCICONTROL_ORACLE
107#include <occiControl.h>
108#endif
109
110namespace oracle {
111namespace occi {
112class Bytes
113{
114
115 public:
116
117 Bytes(const Environment *env = NULL); // default constructor
118
119 Bytes(unsigned char *value, unsigned int count,
120 unsigned int offset = 0, const Environment *env = NULL);
121
122 Bytes(const Bytes &e); // copy constructor
123
124
125 // public methods
126
127 void getBytes(unsigned char *dst, unsigned int count,
128 unsigned int srcBegin = 0,
129 unsigned int dstBegin = 0) const;
130
131 unsigned int length() const;
132
133 unsigned char byteAt(unsigned int index) const;
134
135 bool isNull() const;
136
137 void setNull();
138
139 void operator=(const Bytes &other);
140
141 ~Bytes();
142
143private:
144 // private data members
145 Bytes(OCIEnv *,OCIRaw *) ;
146 Bytes(Ptr<BytesImpl> bytesPtr) ;
147 Ptr<BytesImpl> ptr_;
148 friend class AnyDataImpl;
149 friend class aq::MessageImpl;
150 friend class aq::ProducerImpl;
151 friend class aq::SubscriptionImpl;
152 friend void getVector(const AnyData &any,
153 OCCI_STD_NAMESPACE::vector<Bytes> &vect) ;
154 friend void setVector(AnyData &any,
155 const OCCI_STD_NAMESPACE::vector<Bytes> &vect) ;
156
157};
158
159class Bfile
160{
161 public :
162
163 Bfile();
164 Bfile(const Connection *connectionp) ;
165 Bfile(const Bfile &srcBfile) ;
166 ~Bfile();
167 unsigned int length() const ;
168 OCCI_STD_NAMESPACE::string getDirAlias() const ;
169 UString getUStringDirAlias() const ;
170 OCCI_STD_NAMESPACE::string getFileName() const ;
171 UString getUStringFileName() const ;
172 void setName(const OCCI_STD_NAMESPACE::string &dirAlias,
173 const OCCI_STD_NAMESPACE::string &fileName) ;
174 void setName(const UString &dirAlias, const UString &fileName) ;
175 bool fileExists() const ;
176 Bfile& operator =(const Bfile &srcBfile) ;
177 bool operator ==(const Bfile &srcBfile) const ;
178 bool operator !=(const Bfile &srcBfile) const ;
179 void setNull() ;
180 bool isNull() const ;
181 bool isInitialized() const;
182 void open() ;
183 void close() ;
184 bool isOpen() const ;
185 unsigned int read(unsigned int amt, unsigned char *buffer,
186 unsigned int bufsize, unsigned int offset = 1) const ;
187 Stream* getStream(unsigned int offset = 1,
188 unsigned int amount =0) ;
189 void closeStream(Stream *stream);
190
191 private:
192
193 //Data Members:
194
195 // pointer to the FILE locator
196 OCIBFileLocator *filep;
197
198 // pointer to the ConnectionImpl instance
199 const ConnectionImpl *connp;
200
201 // pointer to the LobStreamImpl instance obtained from this FILE
202 LobStreamImpl *streamp;
203
204 void *bfileExt;
205
206 //Enumerations:
207 enum {MAXDIRNAMELEN = 32, MAXFILENAMELEN = 256};
208
209 //Constructor:
210 Bfile(const Connection *connectionp,
211 OCIBFileLocator *locatorp, bool toCopy = true) ;
212
213 //Methods:
214 OCIBFileLocator* getLocator() const;
215 void do_getDirAlias( void * dirAlias, ub2 * dirAliasLen) const ;
216 void do_getFileName( void * fileName, ub2 * fileNameLen) const ;
217 void do_setName( void * alias, ub2 aliasLen,
218 void *fileName, ub2 fileNameLen);
219 // Friends
220 friend class AnyDataImpl;
221 friend class StatementImpl;
222 friend class ResultSetImpl;
223 friend class Blob;
224 friend class Clob;
225 friend class aq::MessageImpl;
226
227 friend void getVector(const AnyData&, OCCI_STD_NAMESPACE::vector<Bfile>&) ;
228 friend void getVector(Statement*, unsigned int,
229 OCCI_STD_NAMESPACE::vector<Bfile>&) ;
230 friend void getVector(ResultSet*, unsigned int ,
231 OCCI_STD_NAMESPACE::vector<Bfile>&) ;
232 friend void setVector(AnyData&, const OCCI_STD_NAMESPACE::vector<Bfile>&) ;
233 friend void do_setVectorOfBfile(Statement*, unsigned int,
234 const OCCI_STD_NAMESPACE::vector<Bfile>&, void *, unsigned int,
235 void *, unsigned int ) ;
236
237#ifdef ORAXB8_DEFINED
238 friend void readVectorOfBfiles(const Connection *conn,
239 OCCI_STD_NAMESPACE::vector<Bfile> &vec,
240 oraub8 *byte_amts, oraub8 *offsets,
241 unsigned char *buffers[], oraub8 *buffer_lens);
242#endif
243};
244
245
246#ifdef ORAXB8_DEFINED
247// See the end of this file for implementation of LobRegion
248template < typename lobType > class LobRegion
249{
250 private:
251 lobType *_primary;
252 oraub8 _primaryOffset;
253 oraub8 _offset;
254 oraub8 _length;
255 OCCI_STD_NAMESPACE::string _mimeType;
256
257 void setPrimary(const ConnectionImpl *connp,
258 OCILobLocator *locator);
259
260 public:
261 LobRegion();
262 ~LobRegion();
263 lobType *getPrimary();
264 oraub8 getPrimaryOffset();
265 oraub8 getOffset();
266 oraub8 getLength();
267 OCCI_STD_NAMESPACE::string getMimeType();
268
269 friend class Blob;
270 friend class Clob;
271};
272
273typedef LobRegion<Blob> BlobRegion;
274typedef LobRegion<Clob> ClobRegion;
275#endif
276
277
278class Blob
279{
280 public:
281
282 Blob();
283 Blob(const Connection *connectionp) ;
284 Blob(const Blob &srcBlob) ;
285 ~Blob();
286 unsigned int getChunkSize() const ;
287 unsigned int length() const ;
288 Blob& operator =(const Blob &srcBlob) ;
289 bool operator ==(const Blob &srcBlob) const ;
290 bool operator !=(const Blob &srcBlob) const ;
291 void setNull() ;
292 bool isNull() const ;
293 void setEmpty() ;
294 void setEmpty(const Connection *connectionp) ;
295 bool isInitialized() const;
296 void open(LobOpenMode mode=OCCI_LOB_READWRITE) ;
297 void close() ;
298 bool isOpen() const ;
299 void copy(const Blob &srcBlob, unsigned int numBytes,
300 unsigned int dstOffset =1, unsigned int srcOffset =1) ;
301 void copy(const Bfile &srcBfile, unsigned int numBytes,
302 unsigned int dstOffset =1, unsigned int srcOffset =1) ;
303 void append(const Blob &srcBlob) ;
304 unsigned int read(unsigned int amt, unsigned char *buffer,
305 unsigned int bufsize, unsigned int offset = 1) const ;
306 unsigned int write(unsigned int amt, unsigned char *buffer,
307 unsigned int bufsize, unsigned int offset = 1) ;
308 unsigned int writeChunk(unsigned int amt, unsigned char *buffer,
309 unsigned int bufsize, unsigned int offset = 1) ;
310 void trim(unsigned int newlen) ;
311 Stream* getStream(unsigned int offset = 1,
312 unsigned int amount =0) ;
313 void closeStream(Stream *stream);
314 LobOptionValue getOptions(LobOptionType optType);
315 void setOptions(LobOptionType optType, LobOptionValue value);
316 OCCI_STD_NAMESPACE::string getContentType(void);
317 void setContentType(const OCCI_STD_NAMESPACE::string contentType);
318
319 void getDeduplicateRegions(OCCI_STD_NAMESPACE::vector<BlobRegion> &regions);
320 private:
321
322 //Data Members:
323
324 // pointer to the BLOB locator
325 OCIBlobLocator *lobp;
326
327 // pointer to the ConnectionImpl instance
328 const ConnectionImpl *connp;
329
330 // pointer to the LobStreamImpl instance obtained from this LOB
331 LobStreamImpl *streamp;
332
333 //for future use !
334 void *blobExt;
335
336 //Constructor:
337 Blob(const Connection *connectionp,
338 OCIBlobLocator *locatorp, bool toCopy=true) ;
339
340 //Methods:
341 OCIBlobLocator* getLocator() const;
342
343 // Friends
344 friend class AnyDataImpl;
345 friend class StatementImpl;
346 friend class ResultSetImpl;
347
348#ifdef ORAXB8_DEFINED
349 friend void
350 LobRegion<Blob>::setPrimary(const ConnectionImpl *connp,
351 OCILobLocator *locator);
352#endif
353 friend void getVector(const AnyData&, OCCI_STD_NAMESPACE::vector<Blob>&) ;
354 friend void getVector(Statement*, unsigned int,
355 OCCI_STD_NAMESPACE::vector<Blob>&) ;
356 friend void getVector(ResultSet*, unsigned int,
357 OCCI_STD_NAMESPACE::vector<Blob>&) ;
358 friend void setVector(AnyData&, const OCCI_STD_NAMESPACE::vector<Blob>&) ;
359 friend void do_setVectorOfBlob(Statement*, unsigned int,
360 const OCCI_STD_NAMESPACE::vector<Blob>&, void *,
361 unsigned int, void *, unsigned int ) ;
362#ifdef ORAXB8_DEFINED
363 friend void readVectorOfBlobs(const Connection *conn,
364 OCCI_STD_NAMESPACE::vector<Blob> &vec,
365 oraub8 *byte_amts, oraub8 *offsets,
366 unsigned char *buffers[], oraub8 *buffer_lens);
367 friend void writeVectorOfBlobs(const Connection *conn,
368 OCCI_STD_NAMESPACE::vector<Blob> &vec,
369 oraub8 *byte_amts, oraub8 *offsets,
370 unsigned char *buffers[], oraub8 *buffer_lens);
371#endif
372};
373
374class Clob
375{
376 public:
377
378 Clob();
379 Clob(const Connection *connectionp) ;
380 Clob(const Clob &srcClob) ;
381 ~Clob();
382 unsigned int getChunkSize() const ;
383 unsigned int length() const ;
384 OCCI_STD_NAMESPACE::string getCharSetId() const;
385 CharSetForm getCharSetForm() const;
386 void setCharSetId( const OCCI_STD_NAMESPACE::string &charset) ;
387 void setCharSetForm( CharSetForm csfrm) ;
388 Clob& operator =(const Clob &srcClob) ;
389 bool operator ==(const Clob &srcClob) const ;
390 bool operator !=(const Clob &srcClob) const ;
391 void setNull() ;
392 bool isNull() const ;
393 void setEmpty() ;
394 void setEmpty(const Connection *connectionp) ;
395 bool isInitialized() const;
396 void open(LobOpenMode mode=OCCI_LOB_READWRITE) ;
397 void close() ;
398 bool isOpen() const ;
399 void copy(const Clob &srcClob, unsigned int numBytes,
400 unsigned int dstOffset = 1, unsigned int srcOffset = 1) ;
401 void copy(const Bfile &srcBfile, unsigned int numBytes,
402 unsigned int dstOffset = 1, unsigned int srcOffset = 1) ;
403 void append(const Clob &srcClob) ;
404 unsigned int read(unsigned int amt, unsigned char *buffer,
405 unsigned int bufsize, unsigned int offset = 1) const;
406 unsigned int read(unsigned int amt, utext *buffer,
407 unsigned int bufsize, unsigned int offset = 1) const;
408 unsigned int write(unsigned int amt, unsigned char *buffer,
409 unsigned int bufsize, unsigned int offset = 1 );
410 unsigned int write(unsigned int amt, utext *buffer,
411 unsigned int bufsize, unsigned int offset = 1 );
412 unsigned int writeChunk(unsigned int amt, unsigned char *buffer,
413 unsigned int bufsize, unsigned int offset = 1 );
414 unsigned int writeChunk(unsigned int amt, utext *buffer,
415 unsigned int bufsize, unsigned int offset = 1 );
416 void trim(unsigned int newlen) ;
417 Stream* getStream(unsigned int offset = 1,
418 unsigned int amount =0 );
419 void closeStream(Stream *stream);
420 LobOptionValue getOptions(LobOptionType optType);
421 void setOptions(LobOptionType optType, LobOptionValue value);
422 OCCI_STD_NAMESPACE::string getContentType(void);
423 void setContentType(const OCCI_STD_NAMESPACE::string contentType);
424
425 UString getCharSetIdUString() const;
426 void setCharSetIdUString( const UString &charset) ;
427
428 void getDeduplicateRegions(OCCI_STD_NAMESPACE::vector<ClobRegion> &regions);
429
430 private:
431
432 //Data Members:
433
434 // pointer to the CLOB locator
435 OCIClobLocator *lobp;
436
437 // pointer to the ConnectionImpl instance
438 const ConnectionImpl *connp;
439
440 // pointer to the LobStreamImpl instance obtained from this LOB
441 LobStreamImpl *streamp;
442
443 //charset id
444 ub2 charsetId;
445
446 //charset form
447 CharSetForm charsetForm;
448
449 //for future use !
450 void *clobExt;
451
452 //Constructor:
453 Clob(const Connection *connectionp,
454 OCIClobLocator *locatorp, bool toCopy =true ) ;
455
456 //Methods:
457 OCIClobLocator* getLocator() const;
458 unsigned int do_read( unsigned int amt, void *buffer,
459 unsigned int bufsize, unsigned int offset) const;
460 unsigned int do_write( unsigned int amt, void *buffer,
461 unsigned int bufsize, unsigned int offset) ;
462 unsigned int do_writeChunk( unsigned int amt, void *buffer,
463 unsigned int bufsize, unsigned int offset) ;
464
465 // Friends
466 friend class AnyDataImpl;
467 friend class StatementImpl;
468 friend class ResultSetImpl;
469
470#ifdef ORAXB8_DEFINED
471 friend void
472 LobRegion<Clob>::setPrimary(const ConnectionImpl *connp,
473 OCILobLocator *locator);
474#endif
475 friend void getVector(const AnyData&, OCCI_STD_NAMESPACE::vector<Clob>&) ;
476 friend void getVector(Statement*, unsigned int,
477 OCCI_STD_NAMESPACE::vector<Clob>&) ;
478 friend void getVector(ResultSet*, unsigned int,
479 OCCI_STD_NAMESPACE::vector<Clob>&) ;
480 friend void setVector(AnyData&, const OCCI_STD_NAMESPACE::vector<Clob>&) ;
481 friend void do_setVectorOfClob(Statement*, unsigned int,
482 const OCCI_STD_NAMESPACE::vector<Clob>&, void *,
483 unsigned int, void *, unsigned int ) ;
484#ifdef ORAXB8_DEFINED
485 friend void readVectorOfClobs(const Connection *conn,
486 OCCI_STD_NAMESPACE::vector<Clob> &vec,
487 oraub8 *byte_amts, oraub8 *char_amts, oraub8 *offsets,
488 unsigned char *buffers[], oraub8 *buffer_lens);
489 friend void writeVectorOfClobs(const Connection *conn,
490 OCCI_STD_NAMESPACE::vector<Clob> &vec,
491 oraub8 *byte_amts, oraub8 *char_amts, oraub8 *offsets,
492 unsigned char *buffers[], oraub8 *buffer_lens);
493 friend void readVectorOfClobs(const Connection *conn,
494 OCCI_STD_NAMESPACE::vector<Clob> &vec,
495 oraub8 *byte_amts, oraub8 *char_amts, oraub8 *offsets,
496 utext *buffers[], oraub8 *buffer_lens);
497 friend void writeVectorOfClobs(const Connection *conn,
498 OCCI_STD_NAMESPACE::vector<Clob> &vec,
499 oraub8 *byte_amts, oraub8 *char_amts, oraub8 *offsets,
500 utext *buffers[], oraub8 *buffer_lens);
501#endif
502};
503
504class Number
505{
506
507 public:
508
509 // Constructors
510 /* default constructor added */
511 Number();
512 Number(const Number &srcNum);
513 Number(long double val) ;
514 Number(double val) ;
515 Number(float val) ;
516 Number(long val) ;
517 Number(int val) ;
518 Number(short val) ;
519 Number(char val) ;
520 Number(signed char val);
521 Number(unsigned long val) ;
522 Number(unsigned int val) ;
523 Number(unsigned short val) ;
524 Number(unsigned char val) ;
525
526 ~Number();
527 // Methods
528 const Number abs() const ;
529 // unary negate
530 const Number operator-() ;
531 // unary increment
532 Number& operator++() ;
533 const Number operator++(int) ;
534 // unary decrement
535 Number& operator--() ;
536 const Number operator--(int) ;
537 // assigment operator
538 Number& operator=(const Number &a);
539 // add and assign
540 Number& operator+=(const Number &a) ;
541 // subtract and assign
542 Number& operator-=(const Number &a) ;
543 // Mulitply an assign
544 Number& operator*=(const Number &a) ;
545 // divide and assign
546 Number& operator/=(const Number &a) ;
547 // Modulo and assign
548 Number& operator%=(const Number &a) ;
549 // casting operators
550 operator long() const;
551 operator int() const;
552 operator short() const;
553 operator char() const;
554 operator signed char() const;
555 operator unsigned long() const;
556 operator unsigned int() const;
557 operator unsigned short() const;
558 operator unsigned char() const;
559 operator long double() const;
560 operator double() const;
561 operator float() const;
562 // Decimal shift
563 const Number shift(int val) const ;
564 // Integer Power
565 const Number intPower(int val) const ;
566 const Number ceil() const ;
567 const Number floor() const ;
568 const Number squareroot() const ;
569 int sign() const ;
570 // conversion routines
571 // Format Number and return as a OCCI_STD_NAMESPACE::string
572 OCCI_STD_NAMESPACE::string toText(const Environment *envp,
573 const OCCI_STD_NAMESPACE::string &fmt,
574 const OCCI_STD_NAMESPACE::string &nlsParam="") const
575 ;
576 UString toText(const Environment *envp,
577 const UString &fmt,const UString &nlsParam) const
578 ;
579 // Create an Number from formatted text
580 void fromText(const Environment *envp,
581 const OCCI_STD_NAMESPACE::string &number,
582 const OCCI_STD_NAMESPACE::string &fmt,
583 const OCCI_STD_NAMESPACE::string &nlsParam = "")
584 ;
585 void fromText(const Environment *envp,
586 const UString &number,
587 const UString &fmt, const UString &nlsParam);
588 void fromBytes(const Bytes &s) ;
589 Bytes toBytes() const;
590 // truncate digits
591 const Number trunc(int decplace) const ;
592 // round to the decplace place.
593 const Number round(int decplace) const ;
594 // returns an Number with digits decimal digits
595 const Number prec(int digits) const ;
596 const Number sin() const ;
597 const Number cos() const ;
598 const Number tan() const ;
599 const Number hypSin() const ;
600 const Number hypCos() const ;
601 const Number hypTan() const ;
602 const Number arcSin() const ;
603 const Number arcCos() const ;
604 const Number arcTan() const ;
605 const Number arcTan2(const Number &val) const;
606 const Number power(const Number &val) const;
607 const Number exp() const ;
608 const Number ln() const ;
609 const Number log(const Number &val) const;
610 bool isNull() const;
611 void setNull();
612 private:
613 /* Private constructor for constructing number from methods inside */
614 Number(const OCINumber &result);
615 OCINumber getOCINumber() const;
616
617 OCINumber data;
618 /* a flag to indicate if the Number is null */
619 bool numberIsNull;
620 void *numberExt;
621
622 // a >= b
623 friend bool operator>=(const Number &a, const Number &b);
624 // a < = b
625 friend bool operator<=(const Number &a, const Number &b);
626 // a > b
627 friend bool operator>(const Number &a, const Number &b);
628 // a < b
629 friend bool operator<(const Number &a, const Number &b);
630
631 friend class IntervalDS;
632 friend class IntervalYM;
633 friend const IntervalYM operator*(const IntervalYM &a,
634 const Number& factor) ;
635 friend const IntervalDS operator*(const IntervalDS &a,
636 const Number& factor) ;
637 friend const IntervalYM operator/(const IntervalYM &a,
638 const Number &factor) ;
639 friend const IntervalDS operator/(const IntervalDS &a,
640 const Number &factor) ;
641 friend class ResultSetImpl;
642 friend class StatementImpl;
643 friend class AnyDataImpl;
644 friend void getVector(const AnyData &any,
645 OCCI_STD_NAMESPACE::vector<Number> &vect);
646 friend void setVector(AnyData &any,
647 const OCCI_STD_NAMESPACE::vector<Number> &vect) ;
648 friend Number MetaData::getNumber(MetaData::AttrId attrid) const ;
649 friend void getVector(Statement *stmt, unsigned int paramIndex,
650 OCCI_STD_NAMESPACE::vector<Number> &vect) ;
651 friend void do_setVectorOfNumber(Statement *stmt, unsigned int paramIndex,
652 const OCCI_STD_NAMESPACE::vector<Number> &vect, void *schemaName,
653 unsigned int schemaNameLen,
654 void *typeName, unsigned int typeNameLen);
655 friend void getVector(ResultSet *rs, unsigned int colIndex,
656 OCCI_STD_NAMESPACE::vector<Number> &vect);
657
658};
659
660class Date
661{
662 public:
663
664 // Constructors
665 Date();
666 Date(const Date &a);
667 Date(const Environment *envp,int year = 1,unsigned int month = 1,
668 unsigned int day = 1,unsigned int hour = 0,
669 unsigned int minute = 0, unsigned int seconds = 0);
670 ~Date();
671 // Methods
672
673 void setDate(int year = 1,unsigned int month = 1,unsigned int day = 1,
674 unsigned int hour = 0,unsigned int minute = 0,
675 unsigned int seconds = 0);
676 void getDate(int &year,unsigned int &month,unsigned int &day,
677 unsigned int &hour ,unsigned int &min ,unsigned int &sec) const;
678 Bytes toBytes() const ;
679 void fromBytes(const Bytes &byteStream,
680 const Environment *envp = NULL);
681 OCCI_STD_NAMESPACE::string toText(
682 const OCCI_STD_NAMESPACE::string &fmt = "",
683 const OCCI_STD_NAMESPACE::string &nlsParam = "") const;
684 UString toText(
685 const UString &fmt ,
686 const UString &nlsParam ) const;
687 void fromText(const OCCI_STD_NAMESPACE::string &datestr,
688 const OCCI_STD_NAMESPACE::string &fmt = "",
689 const OCCI_STD_NAMESPACE::string &nlsParam = "",
690 const Environment *envp = NULL);
691 void fromText(const UString &datestr,
692 const UString &fmt , const UString &nlsParam ,
693 const Environment *envp = NULL);
694 Date toZone(const OCCI_STD_NAMESPACE::string &zone1,
695 const OCCI_STD_NAMESPACE::string &zone2) const;
696 Date& operator=(const Date &d);
697 Date addMonths(int i) const;
698 Date addDays(int i) const ;
699 Date lastDay() const ;
700 IntervalDS daysBetween(const Date &d) const;
701 Date nextDay(const OCCI_STD_NAMESPACE::string &dow) const;
702 Date nextDay(const UString &dow) const;
703 bool isNull() const;
704 void setNull();
705 static Date getSystemDate(const Environment *envp) ;
706
707 private:
708 OCIDate date;
709 const EnvironmentImpl *envp;
710 bool dateIsNull;
711 void *dateExt;
712
713 /* private constructor */
714 Date(const Environment *env,OCIDate dateval);
715 OCIDate getOCIDate() const;
716 void constructHourAndMinute(sb4 &seconds, sb4 &hours, sb4 &minutes) const;
717 friend bool operator==(const Date &a,const Date &b);
718 friend bool operator>(const Date &a,const Date &b);
719 friend bool operator<(const Date &a,const Date &b);
720 friend bool operator!=(const Date &a,const Date &b);
721 friend bool operator>=(const Date &a,const Date &b);
722 friend bool operator<=(const Date &a,const Date &b);
723 friend class ResultSetImpl;
724 friend class StatementImpl;
725 friend class AnyDataImpl;
726 friend class aq::MessageImpl;
727 friend void getVector(const AnyData &any,
728 OCCI_STD_NAMESPACE::vector<Date> &vect) ;
729 friend void setVector(AnyData &any,
730 const OCCI_STD_NAMESPACE::vector<Date> &vect);
731 friend void getVector(Statement *stmt, unsigned int paramIndex,
732 OCCI_STD_NAMESPACE::vector<Date> &vect) ;
733 friend void do_setVectorOfDate(Statement *stmt, unsigned int paramIndex,
734 const OCCI_STD_NAMESPACE::vector<Date> &vect, void *schemaName,
735 unsigned int schemaNameLen,void *typeName, unsigned int typeNameLen) ;
736 friend void getVector(ResultSet *rs, unsigned int colIndex,
737 OCCI_STD_NAMESPACE::vector<Date> &vect) ;
738
739}; //class Date
740
741class Timestamp
742{
743 public:
744 Timestamp() ;
745
746 Timestamp( const Environment *env, int year=1,
747 unsigned int month=1, unsigned int day=1, unsigned int hour=0,
748 unsigned int min=0 ,unsigned int sec=0, unsigned int fs=0,
749 int tzhour=0, int tzmin=0) ;
750 Timestamp( const Environment *env, int year,
751 unsigned int month, unsigned int day, unsigned int hour,
752 unsigned int min ,unsigned int sec, unsigned int fs,
753 const OCCI_STD_NAMESPACE::string &timezone);
754 Timestamp( const Environment *env, int year,
755 unsigned int month, unsigned int day, unsigned int hour,
756 unsigned int min ,unsigned int sec, unsigned int fs,
757 const UString &timezone);
758 Timestamp( const Timestamp &src) ;
759 ~Timestamp();
760
761 void getTimeZoneOffset( int &hour, int &minute) const ;
762 void getTime( unsigned int &hour, unsigned int &minute,
763 unsigned int &second, unsigned int &fs) const ;
764 void getDate( int &year, unsigned int &month, unsigned int &day )const ;
765 OCCI_STD_NAMESPACE::string toText(const OCCI_STD_NAMESPACE::string &fmt,
766 unsigned int fsprec,
767 const OCCI_STD_NAMESPACE::string &nlsParam ="") const ;
768 UString toText(const UString &fmt,
769 unsigned int fsprec, const UString &nlsParam ) const ;
770 void setTimeZoneOffset( int hour, int minute) ;
771 void setTime( unsigned int hour, unsigned int minute,
772 unsigned int second, unsigned int fs) ;
773 void setDate( int year, unsigned int month, unsigned int day ) ;
774 void setNull() ;
775 void fromText( const OCCI_STD_NAMESPACE::string &timestmpStr,
776 const OCCI_STD_NAMESPACE::string &fmt ,
777 const OCCI_STD_NAMESPACE::string &nlsParam= "",
778 const Environment *env =NULL);
779 void fromText( const UString &timestmpStr,
780 const UString &fmt , const UString &nlsParam,
781 const Environment *env =NULL);
782 bool isNull() const;
783 Timestamp & operator =( const Timestamp &src) ;
784 const IntervalYM subYM(const Timestamp& val) const ;
785 const IntervalDS subDS(const Timestamp& val) const ;
786 const Timestamp intervalAdd(const IntervalDS& val) const ;
787 const Timestamp intervalSub(const IntervalDS& val) const ;
788 const Timestamp intervalAdd(const IntervalYM& val) const ;
789 const Timestamp intervalSub(const IntervalYM& val) const ;
790
791 friend bool operator==(const Timestamp &a,const Timestamp &b);
792 friend bool operator>(const Timestamp &a,const Timestamp &b);
793 friend bool operator<(const Timestamp &a,const Timestamp &b);
794 friend bool operator !=(const Timestamp &a,const Timestamp &b);
795 friend bool operator >=(const Timestamp &a,const Timestamp &b);
796 friend bool operator <=(const Timestamp &a,const Timestamp &b);
797
798 friend class ResultSetImpl;
799 friend class StatementImpl;
800 friend class AnyDataImpl;
801
802 private:
803 OCIDateTime *ocidatetime;
804 Environment *env_;
805 void *timestampExt;
806
807 OCIDateTime *getOCIDateTime() const;
808 void getTZString( OraText *TimeZone, int th, int tm );
809 Timestamp( Environment *env, OCIDateTime *dt, bool toCopy = true) ;
810 void allocateDataMembers( Environment *env) ;
811 void do_TimestampConstruct( const Environment *env, int year,
812 unsigned int month, unsigned int day, unsigned int hour, unsigned int min,
813 unsigned int sec, unsigned int fs, void *tz, int tsize);
814
815 friend void getVector(const AnyData &any,
816 OCCI_STD_NAMESPACE::vector<Timestamp> &vect);
817 friend void setVector(AnyData &any,
818 const OCCI_STD_NAMESPACE::vector<Timestamp> &vect) ;
819 friend Timestamp MetaData::getTimestamp(
820 MetaData::AttrId attrid) const ;
821 friend void getVector(ResultSet *rs, unsigned int,
822 OCCI_STD_NAMESPACE::vector<Timestamp> &vect) ;
823 friend void getVector(Statement *rs, unsigned int,
824 OCCI_STD_NAMESPACE::vector<Timestamp> &vect) ;
825 friend void do_setVectorOfTimestamp(Statement *stmt,
826 unsigned int paramIndex,
827 const OCCI_STD_NAMESPACE::vector<Timestamp> &vect,
828 void *schemaName, unsigned int schemaNameLen,
829 void *typeName, unsigned int typeNameLen) ;
830}; // class Timestamp
831
832class IntervalDS
833{
834
835 public:
836 IntervalDS() ;
837 IntervalDS( const Environment *env,int day=0,
838 int hour=0, int minute=0, int second=0,
839 int fs=0) ;
840 IntervalDS( const IntervalDS &src) ;
841
842 ~IntervalDS();
843
844 int getDay () const ;
845 int getHour () const ;
846 int getMinute () const ;
847 int getSecond() const ;
848 int getFracSec () const ;
849 void set( int day, int hour, int minute, int second, int fracsec) ;
850 void setNull() ;
851 void fromText( const OCCI_STD_NAMESPACE::string &inpstr,
852 const OCCI_STD_NAMESPACE::string &nlsParam ="",
853 const Environment *env=NULL) ;
854 OCCI_STD_NAMESPACE::string toText( unsigned int lfprec, unsigned int fsprec,
855 const OCCI_STD_NAMESPACE::string &nlsParam="") const ;
856 bool isNull() const;
857 IntervalDS& operator =( const IntervalDS &src) ;
858 IntervalDS& operator +=( const IntervalDS &a);
859 IntervalDS& operator -=( const IntervalDS &a);
860 IntervalDS& operator *=( const Number &factor);
861 IntervalDS& operator /=( const Number &factor);
862
863 friend bool operator>(const IntervalDS &a,
864 const IntervalDS &b) ;
865 friend bool operator<(const IntervalDS &a,
866 const IntervalDS &b) ;
867 friend bool operator >=( const IntervalDS &a,
868 const IntervalDS &b);
869 friend bool operator <=( const IntervalDS &a,
870 const IntervalDS &b);
871
872 //UTF16 support
873 void fromUText( const UString &inpstr, const Environment *env=NULL );
874 UString toUText( unsigned int lfprec, unsigned int fsprec) const;
875
876 private:
877 OCIInterval *ociinter;
878 OCIEnv *ocienv;
879 void *intervalDSExt;
880
881 IntervalDS( OCIEnv *env, OCIInterval *inter, bool toCopy = true) ;
882 OCIInterval * getOCIInterval() const;
883
884 void allocateDataMembers( OCIEnv *env) ;
885 friend const IntervalDS Timestamp::subDS(
886 const Timestamp& val) const ;
887 friend const Timestamp Timestamp::intervalAdd(
888 const IntervalDS& val) const ;
889 friend const Timestamp Timestamp::intervalSub(
890 const IntervalDS& val) const ;
891 friend class Date;
892 friend void getVector(ResultSet *rs, unsigned int,
893 OCCI_STD_NAMESPACE::vector<IntervalDS> &vect) ;
894 friend void getVector(Statement *rs, unsigned int,
895 OCCI_STD_NAMESPACE::vector<IntervalDS> &vect) ;
896 friend void do_setVectorOfIntervalDS(Statement *stmt,
897 unsigned int paramIndex,
898 const OCCI_STD_NAMESPACE::vector<IntervalDS> &vect,
899 void *schemaName, unsigned int schemaNameLen,
900 void *typeName, unsigned int typeNameLen) ;
901 friend class StatementImpl;
902 friend class ResultSetImpl;
903 friend class AnyDataImpl;
904 friend void getVector(const AnyData &any,
905 OCCI_STD_NAMESPACE::vector<IntervalDS> &vect);
906 friend void setVector(AnyData &any,
907 const OCCI_STD_NAMESPACE::vector<IntervalDS> &vect) ;
908
909
910}; //class IntervalDS
911
912class IntervalYM
913{
914
915 public:
916 IntervalYM() ;
917 IntervalYM( const Environment *env,int year=0, int month=0) ;
918 IntervalYM( const IntervalYM &src) ;
919 ~IntervalYM();
920
921 int getYear() const ;
922 int getMonth() const ;
923
924 void set( int year, int month) ;
925 void setNull() ;
926 void fromText( const OCCI_STD_NAMESPACE::string &inpstr,
927 const OCCI_STD_NAMESPACE::string &nlsParam="",
928 const Environment *env=NULL) ;
929 OCCI_STD_NAMESPACE::string toText( unsigned int lfprec,
930 const OCCI_STD_NAMESPACE::string &nlsParam="") const;
931 bool isNull() const;
932 IntervalYM & operator =( const IntervalYM &src) ;
933 IntervalYM& operator +=( const IntervalYM &a);
934 IntervalYM& operator -=( const IntervalYM &a);
935 IntervalYM& operator *=( const Number &factor);
936 IntervalYM& operator /=( const Number &factor);
937
938 friend bool operator>(const IntervalYM &a, const IntervalYM &b) ;
939 friend bool operator<( const IntervalYM &a, const IntervalYM &b) ;
940 friend bool operator >=(const IntervalYM &a, const IntervalYM &b);
941 friend bool operator <=(const IntervalYM &a, const IntervalYM &b);
942
943 //UTF16 support
944 void fromUText( const UString &inpstr, const Environment *env=NULL );
945 UString toUText( unsigned int lfprec ) const;
946
947 private:
948 OCIInterval *ociinter;
949 OCIEnv *ocienv;
950 void *intervalYMExt;
951
952 IntervalYM( OCIEnv *env, OCIInterval *inter, bool toCopy = true) ;
953 OCIInterval *getOCIInterval() const;
954 void allocateDataMembers( OCIEnv *env) ;
955 friend const IntervalYM Timestamp :: subYM(
956 const Timestamp& val) const ;
957 friend const Timestamp Timestamp::intervalAdd(
958 const IntervalYM &val) const ;
959 friend const Timestamp Timestamp::intervalSub(
960 const IntervalYM &val) const ;
961
962 friend void getVector(ResultSet *rs, unsigned int,
963 OCCI_STD_NAMESPACE::vector<IntervalYM> &vect) ;
964 friend void getVector(Statement *rs, unsigned int,
965 OCCI_STD_NAMESPACE::vector<IntervalYM> &vect) ;
966 friend void do_setVectorOfIntervalYM(Statement *stmt,
967 unsigned int paramIndex,
968 const OCCI_STD_NAMESPACE::vector<IntervalYM> &vect,
969 void *schemaName, unsigned int schemaNameLen,
970 void *typeName, unsigned int typeNameLen) ;
971
972 friend class StatementImpl;
973 friend class ResultSetImpl;
974 friend class AnyDataImpl;
975 friend void getVector(const AnyData &any,
976 OCCI_STD_NAMESPACE::vector<IntervalYM> &vect);
977 friend void setVector(AnyData &any,
978 const OCCI_STD_NAMESPACE::vector<IntervalYM> &vect) ;
979
980}; //class IntervalYM
981
982
983Number operator+(const Number &a, const Number &b) ;
984Number operator/(const Number &dividend, const Number &divisor) ;
985Number operator*(const Number &a, const Number &b) ;
986Number operator%(const Number &a, const Number &b) ;
987Number operator-(const Number &subtrahend, const Number &subtractor) ;
988bool operator==(const Number &a, const Number &b);
989bool operator!=(const Number &a, const Number &b);
990
991const IntervalYM operator+(const IntervalYM &a, const IntervalYM &b) ;
992const IntervalYM operator-(const IntervalYM &a, const IntervalYM &b) ;
993const IntervalYM operator*(const IntervalYM &a, const Number& factor);
994const IntervalYM operator/(const IntervalYM &a, const Number &factor);
995bool operator==(const IntervalYM &a, const IntervalYM &b) ;
996bool operator!=(const IntervalYM &a, const IntervalYM &b) ;
997
998const IntervalDS operator+(const IntervalDS &a, const IntervalDS &b) ;
999const IntervalDS operator-(const IntervalDS &a, const IntervalDS &b) ;
1000const IntervalDS operator*(const IntervalDS &a, const Number& factor);
1001const IntervalDS operator/(const IntervalDS &a, const Number &factor);
1002bool operator==(const IntervalDS &a, const IntervalDS &b) ;
1003bool operator!=(const IntervalDS &a, const IntervalDS &b) ;
1004
1005
1006typedef struct BFloat
1007{
1008 float value;
1009 bool isNull;
1010
1011 BFloat()
1012 {
1013 isNull = false;
1014 value = 0.;
1015 }
1016} BFloat;
1017
1018typedef struct BDouble
1019{
1020 double value;
1021 bool isNull;
1022
1023 BDouble()
1024 {
1025 isNull = false;
1026 value = 0.;
1027 }
1028} BDouble;
1029
1030/*---------------------------------------------------------------------------
1031 EXPORT FUNCTIONS
1032 ---------------------------------------------------------------------------*/
1033
1034
1035/*---------------------------------------------------------------------------
1036 INTERNAL FUNCTIONS
1037 ---------------------------------------------------------------------------*/
1038
1039
1040#ifdef ORAXB8_DEFINED
1041/*
1042 NAME
1043 Lob Region class
1044
1045 DESCRIPTION
1046 Contains the implementation of the Lob Region template Class.
1047 This class is the underlying implementation for the BlobRegion and
1048 ClobRegion classes.
1049
1050 RELATED DOCUMENTS
1051 Functional/Design Specifications:
1052 18209 - Next Generation LOBs: API
1053 18206 - Next Generation LOBs: Comb. Storage, Compressio & Encryption
1054
1055 EXPORT FUNCTION(S)
1056 LobRegion() - constructors
1057 ~LobRegion() - destructor
1058 getPrimary() - Get the Primary Lob object
1059 getPrimaryOffset() - Get the offset of this region in the Primary Lob.
1060 getOffset() - Get the offset of this region in this lob.
1061 getLength() - Get the length of this region
1062 getMimeType() - Get the mime type of this region
1063
1064 PUBLIC IMPLEMENTATION FUNCTION(S)
1065
1066 INTERNAL FUNCTION(S)
1067 none
1068
1069 EXAMPLES
1070
1071 NOTES
1072*/
1073
1074/*------------------------------ LobRegion ------------------*/
1075/*
1076 NAME
1077 LobRegion - constructor for the class
1078
1079 PARAMETERS
1080 none
1081
1082 DESCRIPTION
1083 default constructor
1084
1085 RETURNS
1086 Nothing
1087
1088 NOTES
1089*/
1090template <typename lobType>
1091LobRegion<lobType>::LobRegion()
1092{
1093 _primary = (lobType *)0;
1094 _primaryOffset = 0;
1095 _offset = 0;
1096 _length = 0;
1097}
1098
1099/*------------------------------ ~LobRegion ------------------*/
1100/*
1101 NAME
1102 ~LobRegion - destructor for the class
1103
1104 PARAMETERS
1105 none
1106
1107 DESCRIPTION
1108 default constructor
1109
1110 RETURNS
1111 Nothing
1112
1113 NOTES
1114*/
1115template <typename lobType>
1116LobRegion<lobType>::~LobRegion()
1117{
1118 if (_primary != (lobType *)0)
1119 {
1120 delete _primary;
1121 }
1122}
1123
1124template <typename lobType>
1125lobType *LobRegion<lobType>::getPrimary()
1126{
1127 return _primary;
1128}
1129
1130template <typename lobType>
1131oraub8 LobRegion<lobType>::getPrimaryOffset()
1132{
1133 return _primaryOffset;
1134}
1135
1136template <typename lobType>
1137oraub8 LobRegion<lobType>::getOffset()
1138{
1139 return _offset;
1140}
1141
1142template <typename lobType>
1143oraub8 LobRegion<lobType>::getLength()
1144{
1145 return _length;
1146}
1147
1148template <typename lobType>
1149OCCI_STD_NAMESPACE::string LobRegion<lobType>::getMimeType()
1150{
1151 return _mimeType;
1152}
1153
1154template <typename lobType>
1155void LobRegion<lobType>::setPrimary(const ConnectionImpl *connp,
1156 OCILobLocator *locator)
1157{
1158 if (locator != (OCILobLocator *)0)
1159 {
1160 _primary = new lobType(connp, locator, true);
1161 }
1162}
1163
1164#endif /* ORAXB8_DEFINED */
1165
1166} /* end of namespace occi */
1167} /* end of namespace oracle */
1168#endif /* OCCIDATA_ORACLE */
1169
1170#endif /* _olint */