ExtString.h File Reference

Go to the source code of this file.

Functions

FENNEL_BEGIN_NAMESPACE void strCatA2 (RegisterRef< char * > *result, RegisterRef< char * > *str1)
 Strcat.
void strCatAF3 (RegisterRef< char * > *result, RegisterRef< char * > *str1, RegisterRef< char * > *str2)
 Sets cbData to length for char as well as varchar.
void strCmpA (RegisterRef< int32_t > *result, RegisterRef< char * > *str1, RegisterRef< char * > *str2)
 StrCmp.
void strCmpOct (RegisterRef< int32_t > *result, RegisterRef< char * > *str1, RegisterRef< char * > *str2)
 StrCmp.
void strCpyA (RegisterRef< char * > *result, RegisterRef< char * > *str)
 StrCpy.
void strLenBitA (RegisterRef< int32_t > *result, RegisterRef< char * > *str)
 StrLen in Bits. Ascii.
void strLenCharA (RegisterRef< int32_t > *result, RegisterRef< char * > *str)
 StrLen in Characters. Ascii.
void strLenOctA (RegisterRef< int32_t > *result, RegisterRef< char * > *str)
 StrLen in Octets. Ascii.
void strOverlayA4 (RegisterRef< char * > *result, RegisterRef< char * > *str, RegisterRef< char * > *overlay, RegisterRef< int32_t > *start)
 Overlay.
void strOverlayA5 (RegisterRef< char * > *result, RegisterRef< char * > *str, RegisterRef< char * > *overlay, RegisterRef< int32_t > *start, RegisterRef< int32_t > *len)
 Overlay. Length specified. Ascii.
void strPosA (RegisterRef< int32_t > *result, RegisterRef< char * > *str, RegisterRef< char * > *find)
 Position of find string in str string. Ascii.
void strSubStringA3 (RegisterRef< char * > *result, RegisterRef< char * > *str, RegisterRef< int32_t > *start)
 SubString.
void strSubStringA4 (RegisterRef< char * > *result, RegisterRef< char * > *str, RegisterRef< int32_t > *start, RegisterRef< int32_t > *len)
 SubString. By Reference. Length specified. Ascii.
void strToLowerA (RegisterRef< char * > *result, RegisterRef< char * > *str)
 ToLower.
void strToUpperA (RegisterRef< char * > *result, RegisterRef< char * > *str)
 ToUpper.
void strTrimA (RegisterRef< char * > *result, RegisterRef< char * > *str, RegisterRef< char * > *trimchar, RegisterRef< int32_t > *trimLeft, RegisterRef< int32_t > *trimRight)
 Trim.
void ExtStringRegister (ExtendedInstructionTable *eit)


Function Documentation

void ExtStringRegister ( ExtendedInstructionTable eit  ) 

Definition at line 433 of file ExtString.cpp.

References ExtendedInstructionTable::add(), STANDARD_TYPE_BINARY, STANDARD_TYPE_CHAR, STANDARD_TYPE_INT_32, STANDARD_TYPE_VARBINARY, STANDARD_TYPE_VARCHAR, strCatA2(), strCatA3(), strCmpA(), strCmpOct(), strCpyA(), strLenBitA(), strLenCharA(), strLenOctA(), strOverlayA4(), strOverlayA5(), strPosA(), strSubStringA3(), strSubStringA4(), strToLowerA(), strToUpperA(), and strTrimA().

Referenced by CalcInit::instance().

00434 {
00435     assert(eit != NULL);
00436 
00437     vector<StandardTypeDescriptorOrdinal> params_2F;
00438     params_2F.push_back(STANDARD_TYPE_CHAR);
00439     params_2F.push_back(STANDARD_TYPE_CHAR);
00440 
00441     vector<StandardTypeDescriptorOrdinal> params_2V;
00442     params_2V.push_back(STANDARD_TYPE_VARCHAR);
00443     params_2V.push_back(STANDARD_TYPE_VARCHAR);
00444 
00445     eit->add(
00446         "strCatA2", params_2F,
00447         (ExtendedInstruction2<char*, char*>*) NULL,
00448         &strCatA2);
00449     eit->add(
00450         "strCatA2", params_2V,
00451         (ExtendedInstruction2<char*, char*>*) NULL,
00452         &strCatA2);
00453 
00454 
00455     vector<StandardTypeDescriptorOrdinal> params_3F;
00456     params_3F.push_back(STANDARD_TYPE_CHAR);
00457     params_3F.push_back(STANDARD_TYPE_CHAR);
00458     params_3F.push_back(STANDARD_TYPE_CHAR);
00459 
00460     vector<StandardTypeDescriptorOrdinal> params_3V;
00461     params_3V.push_back(STANDARD_TYPE_VARCHAR);
00462     params_3V.push_back(STANDARD_TYPE_VARCHAR);
00463     params_3V.push_back(STANDARD_TYPE_VARCHAR);
00464 
00465     eit->add(
00466         "strCatA3", params_3F,
00467         (ExtendedInstruction3<char*, char*, char*>*) NULL,
00468         &strCatA3);
00469 
00470     eit->add(
00471         "strCatA3", params_3V,
00472         (ExtendedInstruction3<char*, char*, char*>*) NULL,
00473         &strCatA3);
00474 
00475     vector<StandardTypeDescriptorOrdinal> params_1N_2F;
00476     params_1N_2F.push_back(STANDARD_TYPE_INT_32);
00477     params_1N_2F.push_back(STANDARD_TYPE_CHAR);
00478     params_1N_2F.push_back(STANDARD_TYPE_CHAR);
00479 
00480     vector<StandardTypeDescriptorOrdinal> params_1N_2V;
00481     params_1N_2V.push_back(STANDARD_TYPE_INT_32);
00482     params_1N_2V.push_back(STANDARD_TYPE_VARCHAR);
00483     params_1N_2V.push_back(STANDARD_TYPE_VARCHAR);
00484 
00485     vector<StandardTypeDescriptorOrdinal> params_1N_1F_1V;
00486     params_1N_1F_1V.push_back(STANDARD_TYPE_INT_32);
00487     params_1N_1F_1V.push_back(STANDARD_TYPE_CHAR);
00488     params_1N_1F_1V.push_back(STANDARD_TYPE_VARCHAR);
00489 
00490     vector<StandardTypeDescriptorOrdinal> params_1N_1V_1F;
00491     params_1N_1V_1F.push_back(STANDARD_TYPE_INT_32);
00492     params_1N_1V_1F.push_back(STANDARD_TYPE_VARCHAR);
00493     params_1N_1V_1F.push_back(STANDARD_TYPE_CHAR);
00494 
00495     eit->add(
00496         "strCmpA", params_1N_2F,
00497         (ExtendedInstruction3<int32_t, char*, char*>*) NULL,
00498         &strCmpA);
00499 
00500     eit->add(
00501         "strCmpA", params_1N_2V,
00502         (ExtendedInstruction3<int32_t, char*, char*>*) NULL,
00503         &strCmpA);
00504 
00505     eit->add(
00506         "strCmpA", params_1N_1F_1V,
00507         (ExtendedInstruction3<int32_t, char*, char*>*) NULL,
00508         &strCmpA);
00509 
00510     eit->add(
00511         "strCmpA", params_1N_1V_1F,
00512         (ExtendedInstruction3<int32_t, char*, char*>*) NULL,
00513         &strCmpA);
00514 
00515     eit->add(
00516         "strCpyA", params_2V,
00517         (ExtendedInstruction2<char*, char*>*) NULL,
00518         &strCpyA);
00519 
00520     eit->add(
00521         "strCpyA", params_2F,
00522         (ExtendedInstruction2<char*, char*>*) NULL,
00523         &strCpyA);
00524 
00525     vector<StandardTypeDescriptorOrdinal> params_1N_2B;
00526     params_1N_2B.push_back(STANDARD_TYPE_INT_32);
00527     params_1N_2B.push_back(STANDARD_TYPE_BINARY);
00528     params_1N_2B.push_back(STANDARD_TYPE_BINARY);
00529 
00530     vector<StandardTypeDescriptorOrdinal> params_1N_2VB;
00531     params_1N_2VB.push_back(STANDARD_TYPE_INT_32);
00532     params_1N_2VB.push_back(STANDARD_TYPE_VARBINARY);
00533     params_1N_2VB.push_back(STANDARD_TYPE_VARBINARY);
00534 
00535     vector<StandardTypeDescriptorOrdinal> params_1N_1B_1VB;
00536     params_1N_1B_1VB.push_back(STANDARD_TYPE_INT_32);
00537     params_1N_1B_1VB.push_back(STANDARD_TYPE_BINARY);
00538     params_1N_1B_1VB.push_back(STANDARD_TYPE_VARBINARY);
00539 
00540     vector<StandardTypeDescriptorOrdinal> params_1N_1VB_1B;
00541     params_1N_1VB_1B.push_back(STANDARD_TYPE_INT_32);
00542     params_1N_1VB_1B.push_back(STANDARD_TYPE_VARBINARY);
00543     params_1N_1VB_1B.push_back(STANDARD_TYPE_BINARY);
00544 
00545     eit->add(
00546         "strCmpOct", params_1N_2B,
00547         (ExtendedInstruction3<int32_t, char*, char*>*) NULL,
00548         &strCmpOct);
00549 
00550     eit->add(
00551         "strCmpOct", params_1N_2VB,
00552         (ExtendedInstruction3<int32_t, char*, char*>*) NULL,
00553         &strCmpOct);
00554 
00555     eit->add(
00556         "strCmpOct", params_1N_1B_1VB,
00557         (ExtendedInstruction3<int32_t, char*, char*>*) NULL,
00558         &strCmpOct);
00559 
00560     eit->add(
00561         "strCmpOct", params_1N_1VB_1B,
00562         (ExtendedInstruction3<int32_t, char*, char*>*) NULL,
00563         &strCmpOct);
00564 
00565     vector<StandardTypeDescriptorOrdinal> params_1N_1F;
00566     params_1N_1F.push_back(STANDARD_TYPE_INT_32);
00567     params_1N_1F.push_back(STANDARD_TYPE_CHAR);
00568 
00569     vector<StandardTypeDescriptorOrdinal> params_1N_1V;
00570     params_1N_1V.push_back(STANDARD_TYPE_INT_32);
00571     params_1N_1V.push_back(STANDARD_TYPE_VARCHAR);
00572 
00573     eit->add(
00574         "strLenBitA", params_1N_1F,
00575         (ExtendedInstruction2<int32_t, char*>*) NULL,
00576         &strLenBitA);
00577     eit->add(
00578         "strLenBitA", params_1N_1V,
00579         (ExtendedInstruction2<int32_t, char*>*) NULL,
00580         &strLenBitA);
00581 
00582     eit->add(
00583         "strLenCharA", params_1N_1F,
00584         (ExtendedInstruction2<int32_t, char*>*) NULL,
00585         &strLenCharA);
00586     eit->add(
00587         "strLenCharA", params_1N_1V,
00588         (ExtendedInstruction2<int32_t, char*>*) NULL,
00589         &strLenCharA);
00590 
00591     eit->add(
00592         "strLenOctA", params_1N_1F,
00593         (ExtendedInstruction2<int32_t, char*>*) NULL,
00594         &strLenOctA);
00595     eit->add(
00596         "strLenOctA", params_1N_1V,
00597         (ExtendedInstruction2<int32_t, char*>*) NULL,
00598         &strLenOctA);
00599 
00600     vector<StandardTypeDescriptorOrdinal> params_1V_2F_2I;
00601     params_1V_2F_2I.push_back(STANDARD_TYPE_VARCHAR);
00602     params_1V_2F_2I.push_back(STANDARD_TYPE_CHAR);
00603     params_1V_2F_2I.push_back(STANDARD_TYPE_CHAR);
00604     params_1V_2F_2I.push_back(STANDARD_TYPE_INT_32);
00605     params_1V_2F_2I.push_back(STANDARD_TYPE_INT_32);
00606 
00607     vector<StandardTypeDescriptorOrdinal> params_3V_2I;
00608     params_3V_2I.push_back(STANDARD_TYPE_VARCHAR);
00609     params_3V_2I.push_back(STANDARD_TYPE_VARCHAR);
00610     params_3V_2I.push_back(STANDARD_TYPE_VARCHAR);
00611     params_3V_2I.push_back(STANDARD_TYPE_INT_32);
00612     params_3V_2I.push_back(STANDARD_TYPE_INT_32);
00613 
00614     eit->add(
00615         "strOverlayA5", params_1V_2F_2I,
00616         (ExtendedInstruction5<char*, char*, char*, int32_t, int32_t>*) NULL,
00617         &strOverlayA5);
00618 
00619     eit->add(
00620         "strOverlayA5", params_3V_2I,
00621         (ExtendedInstruction5<char*, char*, char*, int32_t, int32_t>*) NULL,
00622         &strOverlayA5);
00623 
00624     vector<StandardTypeDescriptorOrdinal> params_1V_2F_1I;
00625     params_1V_2F_1I.push_back(STANDARD_TYPE_VARCHAR);
00626     params_1V_2F_1I.push_back(STANDARD_TYPE_CHAR);
00627     params_1V_2F_1I.push_back(STANDARD_TYPE_CHAR);
00628     params_1V_2F_1I.push_back(STANDARD_TYPE_INT_32);
00629 
00630     vector<StandardTypeDescriptorOrdinal> params_3V_1I;
00631     params_3V_1I.push_back(STANDARD_TYPE_VARCHAR);
00632     params_3V_1I.push_back(STANDARD_TYPE_VARCHAR);
00633     params_3V_1I.push_back(STANDARD_TYPE_VARCHAR);
00634     params_3V_1I.push_back(STANDARD_TYPE_INT_32);
00635 
00636     eit->add(
00637         "strOverlayA4", params_1V_2F_1I,
00638         (ExtendedInstruction4<char*, char*, char*, int32_t>*) NULL,
00639         &strOverlayA4);
00640 
00641     eit->add(
00642         "strOverlayA4", params_3V_1I,
00643         (ExtendedInstruction4<char*, char*, char*, int32_t>*) NULL,
00644         &strOverlayA4);
00645 
00646 
00647     eit->add(
00648         "strPosA", params_1N_2F,
00649         (ExtendedInstruction3<int32_t, char*, char*>*) NULL,
00650         &strPosA);
00651 
00652     eit->add(
00653         "strPosA", params_1N_2V,
00654         (ExtendedInstruction3<int32_t, char*, char*>*) NULL,
00655         &strPosA);
00656 
00657     vector<StandardTypeDescriptorOrdinal> params_1V_1F_1N;
00658     params_1V_1F_1N.push_back(STANDARD_TYPE_VARCHAR);
00659     params_1V_1F_1N.push_back(STANDARD_TYPE_CHAR);
00660     params_1V_1F_1N.push_back(STANDARD_TYPE_INT_32);
00661 
00662     vector<StandardTypeDescriptorOrdinal> params_2V_1N;
00663     params_2V_1N.push_back(STANDARD_TYPE_VARCHAR);
00664     params_2V_1N.push_back(STANDARD_TYPE_VARCHAR);
00665     params_2V_1N.push_back(STANDARD_TYPE_INT_32);
00666 
00667     eit->add(
00668         "strSubStringA3", params_1V_1F_1N,
00669         (ExtendedInstruction3<char*, char*, int32_t>*) NULL,
00670         &strSubStringA3);
00671 
00672     eit->add(
00673         "strSubStringA3", params_2V_1N,
00674         (ExtendedInstruction3<char*, char*, int32_t>*) NULL,
00675         &strSubStringA3);
00676 
00677     vector<StandardTypeDescriptorOrdinal> params_1V_1F_2N;
00678     params_1V_1F_2N.push_back(STANDARD_TYPE_VARCHAR);
00679     params_1V_1F_2N.push_back(STANDARD_TYPE_CHAR);
00680     params_1V_1F_2N.push_back(STANDARD_TYPE_INT_32);
00681     params_1V_1F_2N.push_back(STANDARD_TYPE_INT_32);
00682 
00683     vector<StandardTypeDescriptorOrdinal> params_2V_2N;
00684     params_2V_2N.push_back(STANDARD_TYPE_VARCHAR);
00685     params_2V_2N.push_back(STANDARD_TYPE_VARCHAR);
00686     params_2V_2N.push_back(STANDARD_TYPE_INT_32);
00687     params_2V_2N.push_back(STANDARD_TYPE_INT_32);
00688 
00689     eit->add(
00690         "strSubStringA4", params_1V_1F_2N,
00691         (ExtendedInstruction4<char*, char*, int32_t, int32_t>*) NULL,
00692         &strSubStringA4);
00693 
00694     eit->add(
00695         "strSubStringA4", params_2V_2N,
00696         (ExtendedInstruction4<char*, char*, int32_t, int32_t>*) NULL,
00697         &strSubStringA4);
00698 
00699 
00700     eit->add(
00701         "strToLowerA", params_2F,
00702         (ExtendedInstruction2<char*, char*>*) NULL,
00703         &strToLowerA);
00704 
00705     eit->add(
00706         "strToLowerA", params_2V,
00707         (ExtendedInstruction2<char*, char*>*) NULL,
00708         &strToLowerA);
00709 
00710     eit->add(
00711         "strToUpperA", params_2F,
00712         (ExtendedInstruction2<char*, char*>*) NULL,
00713         &strToUpperA);
00714 
00715     eit->add(
00716         "strToUpperA", params_2V,
00717         (ExtendedInstruction2<char*, char*>*) NULL,
00718         &strToUpperA);
00719 
00720 
00721     // Result of strTrimA is always VC. Other two arg strings can be VC or C
00722 
00723     vector<StandardTypeDescriptorOrdinal> params_1V_1F_1V_2I;
00724     params_1V_1F_1V_2I.push_back(STANDARD_TYPE_VARCHAR);
00725     params_1V_1F_1V_2I.push_back(STANDARD_TYPE_CHAR);
00726     params_1V_1F_1V_2I.push_back(STANDARD_TYPE_VARCHAR);
00727     params_1V_1F_1V_2I.push_back(STANDARD_TYPE_INT_32);
00728     params_1V_1F_1V_2I.push_back(STANDARD_TYPE_INT_32);
00729 
00730     vector<StandardTypeDescriptorOrdinal> params_2V_1F_2I;
00731     params_2V_1F_2I.push_back(STANDARD_TYPE_VARCHAR);
00732     params_2V_1F_2I.push_back(STANDARD_TYPE_VARCHAR);
00733     params_2V_1F_2I.push_back(STANDARD_TYPE_CHAR);
00734     params_2V_1F_2I.push_back(STANDARD_TYPE_INT_32);
00735     params_2V_1F_2I.push_back(STANDARD_TYPE_INT_32);
00736 
00737     // VC, VC, VC
00738     eit->add(
00739         "strTrimA", params_3V_2I,
00740         (ExtendedInstruction5<char*, char*, char*, int32_t, int32_t>*) NULL,
00741         &strTrimA);
00742     // VC, VC, C
00743     eit->add(
00744         "strTrimA", params_2V_1F_2I,
00745         (ExtendedInstruction5<char*, char*, char*, int32_t, int32_t>*) NULL,
00746         &strTrimA);
00747     // VC, C, C
00748     eit->add(
00749         "strTrimA", params_1V_2F_2I,
00750         (ExtendedInstruction5<char*, char*, char*, int32_t, int32_t>*) NULL,
00751         &strTrimA);
00752     // VC, C, VC
00753     eit->add(
00754         "strTrimA", params_1V_1F_1V_2I,
00755         (ExtendedInstruction5<char*, char*, char*, int32_t, int32_t>*) NULL,
00756         &strTrimA);
00757 }

FENNEL_BEGIN_NAMESPACE void strCatA2 ( RegisterRef< char * > *  result,
RegisterRef< char * > *  str1 
)

Strcat.

Ascii. dest = dest || str.

Sets cbData to length for char as well as varchar.

May throw "22001"

If calling with fixed: Must call StrCatA3() first to have length set correctly. Only then subsequent calls to strCatA2() are possible. If concatenating multiple strings, strCatA2 will honor the intermediate length. After final call to strCatA2(), length should equal width, to maintain fixed width string length == width. Behavior may be undefined if, after Calculator exits, length != width.

Definition at line 31 of file ExtString.cpp.

References RegisterRef< TMPLT >::isNull(), StandardTypeDescriptor::isTextArray(), RegisterRef< TMPLT >::length(), RegisterRef< TMPLT >::pointer(), SqlStrCat(), RegisterRef< TMPLT >::storage(), str1, and RegisterRef< TMPLT >::toNull().

Referenced by ExtStringRegister().

00034 {
00035     assert(StandardTypeDescriptor::isTextArray(str1->type()));
00036 
00037     // appending to a null results in null
00038     if (result->isNull() || str1->isNull()) {
00039         result->toNull();
00040         result->length(0);
00041     } else {
00042         result->length(
00043             SqlStrCat(
00044                 result->pointer(),
00045                 result->storage(),
00046                 result->length(),
00047                 str1->pointer(),
00048                 str1->stringLength()));
00049     }
00050 }

void strCatAF3 ( RegisterRef< char * > *  result,
RegisterRef< char * > *  str1,
RegisterRef< char * > *  str2 
)

Sets cbData to length for char as well as varchar.

After final call to strCatA3(), length should equal width, to maintain fixed width string length == width. Behavior may be undefined if, after Calculator exits, length != width. If concatenating multiple strings, strCatA2 will honor the intermediate length set by strCatAF3()

void strCmpA ( RegisterRef< int32_t > *  result,
RegisterRef< char * > *  str1,
RegisterRef< char * > *  str2 
)

StrCmp.

Ascii. Str1 and str2 may be any combination of VARCHAR and/or CHAR. Returns -1, 0, 1.

Definition at line 77 of file ExtString.cpp.

References StandardTypeDescriptor::isTextArray(), str1, str2, RegisterRef< TMPLT >::toNull(), and RegisterRef< TMPLT >::value().

Referenced by ExtStringRegister().

00081 {
00082     assert(StandardTypeDescriptor::isTextArray(str1->type()));
00083 
00084     if (str1->isNull() || str2->isNull()) {
00085         result->toNull();
00086     } else {
00087         result->value(
00088             SqlStrCmp<1,1>(
00089                 str1->pointer(), str1->stringLength(),
00090                 str2->pointer(), str2->stringLength()));
00091     }
00092 }

void strCmpOct ( RegisterRef< int32_t > *  result,
RegisterRef< char * > *  str1,
RegisterRef< char * > *  str2 
)

StrCmp.

Binary (Octal-- comparison is byte-wise) See SQL2003 Part 2 Section 4.3.2. All binary strings can be compared. As an extension to SQL2003, allow inequalities (>,>=, etc.) Follows byte-wise comparison semantics of memcmp(). Returns -1, 0, 1.

Definition at line 95 of file ExtString.cpp.

References StandardTypeDescriptor::isBinaryArray(), SqlStrCmp_Bin(), str1, str2, RegisterRef< TMPLT >::toNull(), and RegisterRef< TMPLT >::value().

Referenced by ExtStringRegister().

00099 {
00100     assert(StandardTypeDescriptor::isBinaryArray(str1->type()));
00101 
00102     if (str1->isNull() || str2->isNull()) {
00103         result->toNull();
00104     } else {
00105         result->value(
00106             SqlStrCmp_Bin(
00107                 str1->pointer(), str1->stringLength(),
00108                 str2->pointer(), str2->stringLength()));
00109     }
00110 }

void strCpyA ( RegisterRef< char * > *  result,
RegisterRef< char * > *  str 
)

StrCpy.

Ascii.

May throw "22001"

Definition at line 113 of file ExtString.cpp.

References RegisterRef< TMPLT >::isNull(), StandardTypeDescriptor::isTextArray(), RegisterRef< TMPLT >::length(), RegisterRef< TMPLT >::pointer(), SqlStrCpy_Var(), STANDARD_TYPE_CHAR, RegisterRef< TMPLT >::storage(), RegisterRef< TMPLT >::stringLength(), RegisterRef< TMPLT >::toNull(), and RegisterReference::type().

Referenced by ExtStringRegister().

00116 {
00117     assert(result->type() == str->type());
00118     assert(StandardTypeDescriptor::isTextArray(str->type()));
00119 
00120     // copy to a null results in null
00121     if (result->isNull() || str->isNull()) {
00122         result->toNull();
00123         result->length(0);
00124     } else {
00125         if (str->type() == STANDARD_TYPE_CHAR) {
00126             result->length(
00127                 SqlStrCpy_Fix<1,1>(
00128                     result->pointer(),
00129                     result->storage(),
00130                     str->pointer(),
00131                     str->stringLength()));
00132         } else {
00133             result->length(
00134                 SqlStrCpy_Var(
00135                     result->pointer(),
00136                     result->storage(),
00137                     str->pointer(),
00138                     str->stringLength()));
00139         }
00140     }
00141 }

void strLenBitA ( RegisterRef< int32_t > *  result,
RegisterRef< char * > *  str 
)

StrLen in Bits. Ascii.

Definition at line 145 of file ExtString.cpp.

References RegisterRef< TMPLT >::isNull(), StandardTypeDescriptor::isTextArray(), SqlStrLenBit(), RegisterRef< TMPLT >::stringLength(), RegisterRef< TMPLT >::toNull(), RegisterReference::type(), and RegisterRef< TMPLT >::value().

Referenced by ExtStringRegister().

00148 {
00149     assert(StandardTypeDescriptor::isTextArray(str->type()));
00150 
00151     if (str->isNull()) {
00152         result->toNull();
00153     } else {
00154         result->value(SqlStrLenBit(str->stringLength()));
00155     }
00156 }

void strLenCharA ( RegisterRef< int32_t > *  result,
RegisterRef< char * > *  str 
)

StrLen in Characters. Ascii.

Definition at line 159 of file ExtString.cpp.

References RegisterRef< TMPLT >::isNull(), StandardTypeDescriptor::isTextArray(), RegisterRef< TMPLT >::pointer(), RegisterRef< TMPLT >::stringLength(), RegisterRef< TMPLT >::toNull(), RegisterReference::type(), and RegisterRef< TMPLT >::value().

Referenced by ExtStringRegister().

00162 {
00163     assert(StandardTypeDescriptor::isTextArray(str->type()));
00164 
00165     if (str->isNull()) {
00166         result->toNull();
00167     } else {
00168         result->value(
00169             SqlStrLenChar<1,1>(
00170                 str->pointer(),
00171                 str->stringLength()));
00172     }
00173 }

void strLenOctA ( RegisterRef< int32_t > *  result,
RegisterRef< char * > *  str 
)

StrLen in Octets. Ascii.

Definition at line 176 of file ExtString.cpp.

References RegisterRef< TMPLT >::isNull(), StandardTypeDescriptor::isTextArray(), SqlStrLenOct(), RegisterRef< TMPLT >::stringLength(), RegisterRef< TMPLT >::toNull(), RegisterReference::type(), and RegisterRef< TMPLT >::value().

Referenced by ExtStringRegister().

00179 {
00180     assert(StandardTypeDescriptor::isTextArray(str->type()));
00181 
00182     if (str->isNull()) {
00183         result->toNull();
00184     } else {
00185         result->value(SqlStrLenOct(str->stringLength()));
00186     }
00187 }

void strOverlayA4 ( RegisterRef< char * > *  result,
RegisterRef< char * > *  str,
RegisterRef< char * > *  overlay,
RegisterRef< int32_t > *  start 
)

Overlay.

Length unspecified -- to end. Ascii.

May throw "22001" or "22011"

Definition at line 190 of file ExtString.cpp.

References RegisterRef< TMPLT >::isNull(), StandardTypeDescriptor::isTextArray(), RegisterRef< TMPLT >::length(), RegisterRef< TMPLT >::pointer(), STANDARD_TYPE_VARCHAR, RegisterRef< TMPLT >::storage(), RegisterRef< TMPLT >::stringLength(), RegisterRef< TMPLT >::toNull(), RegisterReference::type(), and RegisterRef< TMPLT >::value().

Referenced by ExtStringRegister().

00195 {
00196     assert(result->type() == STANDARD_TYPE_VARCHAR);
00197     assert(str->type() == overlay->type());
00198     assert(StandardTypeDescriptor::isTextArray(str->type()));
00199 
00200     // overlay to a null results in null
00201     if (result->isNull() || str->isNull() ||
00202         overlay->isNull() || start->isNull()) {
00203         result->toNull();
00204         result->length(0);
00205     } else {
00206         result->length(
00207             SqlStrOverlay<1,1>(
00208                 result->pointer(),
00209                 result->storage(),
00210                 str->pointer(),
00211                 str->stringLength(),
00212                 overlay->pointer(),
00213                 overlay->stringLength(),
00214                 start->value(),
00215                 0,
00216                 false));
00217     }
00218 }

void strOverlayA5 ( RegisterRef< char * > *  result,
RegisterRef< char * > *  str,
RegisterRef< char * > *  overlay,
RegisterRef< int32_t > *  start,
RegisterRef< int32_t > *  len 
)

Overlay. Length specified. Ascii.

Definition at line 221 of file ExtString.cpp.

References RegisterRef< TMPLT >::isNull(), StandardTypeDescriptor::isTextArray(), RegisterRef< TMPLT >::length(), RegisterRef< TMPLT >::pointer(), STANDARD_TYPE_VARCHAR, RegisterRef< TMPLT >::storage(), RegisterRef< TMPLT >::stringLength(), RegisterRef< TMPLT >::toNull(), RegisterReference::type(), and RegisterRef< TMPLT >::value().

Referenced by ExtStringRegister().

00227 {
00228     assert(result->type() == STANDARD_TYPE_VARCHAR);
00229     assert(str->type() == overlay->type());
00230     assert(StandardTypeDescriptor::isTextArray(str->type()));
00231 
00232     // overlay to a null results in null
00233     if (result->isNull() || str->isNull() ||
00234         overlay->isNull() || start->isNull() || len->isNull()) {
00235         result->toNull();
00236         result->length(0);
00237     } else {
00238         result->length(
00239             SqlStrOverlay<1,1>(
00240                 result->pointer(),
00241                 result->storage(),
00242                 str->pointer(),
00243                 str->stringLength(),
00244                 overlay->pointer(),
00245                 overlay->stringLength(),
00246                 start->value(),
00247                 len->value(),
00248                 true));
00249     }
00250 }

void strPosA ( RegisterRef< int32_t > *  result,
RegisterRef< char * > *  str,
RegisterRef< char * > *  find 
)

Position of find string in str string. Ascii.

Definition at line 253 of file ExtString.cpp.

References RegisterRef< TMPLT >::isNull(), StandardTypeDescriptor::isTextArray(), RegisterRef< TMPLT >::pointer(), RegisterRef< TMPLT >::stringLength(), RegisterRef< TMPLT >::toNull(), RegisterReference::type(), and RegisterRef< TMPLT >::value().

Referenced by ExtStringRegister().

00257 {
00258     assert(str->type() == find->type());
00259     assert(StandardTypeDescriptor::isTextArray(str->type()));
00260 
00261     if (str->isNull() || find->isNull()) {
00262         result->toNull();
00263     } else {
00264         result->value(
00265             SqlStrPos<1,1>(
00266                 str->pointer(),
00267                 str->stringLength(),
00268                 find->pointer(),
00269                 find->stringLength()));
00270     }
00271 }

void strSubStringA3 ( RegisterRef< char * > *  result,
RegisterRef< char * > *  str,
RegisterRef< int32_t > *  start 
)

SubString.

By reference. Length not specified -- to end. Ascii.

May throw "22001" or "22011"

Definition at line 274 of file ExtString.cpp.

References RegisterRef< TMPLT >::isNull(), StandardTypeDescriptor::isTextArray(), RegisterRef< TMPLT >::length(), RegisterRef< TMPLT >::pointer(), STANDARD_TYPE_VARCHAR, RegisterRef< TMPLT >::storage(), RegisterRef< TMPLT >::stringLength(), RegisterRef< TMPLT >::toNull(), RegisterReference::type(), and RegisterRef< TMPLT >::value().

Referenced by ExtStringRegister().

00278 {
00279     assert(result->type() == STANDARD_TYPE_VARCHAR);
00280     assert(StandardTypeDescriptor::isTextArray(str->type()));
00281 
00282     // substring to a null results in null
00283     if (result->isNull() || str->isNull() || start->isNull()) {
00284         result->toNull();
00285         result->length(0);
00286     } else {
00287         // Don't try anything fancy with RegisterRef accessors. KISS.
00288         char * ptr = result->pointer(); // preserve old value if possible
00289         // TODO: Not sure why cast from char* to char const * is required below.
00290         int32_t newLen = SqlStrSubStr<1,1>(
00291             const_cast<char const **>(&ptr),
00292             result->storage(),
00293             str->pointer(),
00294             str->stringLength(),
00295             start->value(),
00296             0,
00297             false);
00298         result->pointer(ptr, newLen);
00299     }
00300 }

void strSubStringA4 ( RegisterRef< char * > *  result,
RegisterRef< char * > *  str,
RegisterRef< int32_t > *  start,
RegisterRef< int32_t > *  len 
)

SubString. By Reference. Length specified. Ascii.

Definition at line 303 of file ExtString.cpp.

References RegisterRef< TMPLT >::isNull(), StandardTypeDescriptor::isTextArray(), RegisterRef< TMPLT >::length(), RegisterRef< TMPLT >::pointer(), STANDARD_TYPE_VARCHAR, RegisterRef< TMPLT >::storage(), RegisterRef< TMPLT >::stringLength(), RegisterRef< TMPLT >::toNull(), RegisterReference::type(), and RegisterRef< TMPLT >::value().

Referenced by ExtStringRegister().

00308 {
00309     assert(result->type() == STANDARD_TYPE_VARCHAR);
00310     assert(StandardTypeDescriptor::isTextArray(str->type()));
00311 
00312     // substring to a null results in null
00313     if (result->isNull() || str->isNull() ||
00314         start->isNull() || len->isNull()) {
00315         result->toNull();
00316         result->length(0);
00317     } else {
00318         // Don't try anything fancy with RegisterRef accessors. KISS.
00319         char * ptr = result->pointer(); // preserve old value if possible
00320         // TODO: Not sure why cast from char* to char const * is required below.
00321         int32_t newLen = SqlStrSubStr<1,1>(
00322             const_cast<char const **>(&ptr),
00323             result->storage(),
00324             str->pointer(),
00325             str->stringLength(),
00326             start->value(),
00327             len->value(),
00328             true);
00329         result->pointer(ptr, newLen);
00330     }
00331 }

void strToLowerA ( RegisterRef< char * > *  result,
RegisterRef< char * > *  str 
)

ToLower.

Ascii.

May throw "22001".

Definition at line 334 of file ExtString.cpp.

References RegisterRef< TMPLT >::isNull(), StandardTypeDescriptor::isTextArray(), RegisterRef< TMPLT >::length(), RegisterRef< TMPLT >::pointer(), STANDARD_TYPE_CHAR, RegisterRef< TMPLT >::storage(), RegisterRef< TMPLT >::stringLength(), RegisterRef< TMPLT >::toNull(), and RegisterReference::type().

Referenced by ExtStringRegister().

00337 {
00338     assert(StandardTypeDescriptor::isTextArray(str->type()));
00339     assert(str->type() == result->type());
00340 
00341     // tolower to a null results in null
00342     if (result->isNull() || str->isNull()) {
00343         result->toNull();
00344         result->length(0);
00345     } else {
00346         // fixed width case: length should be harmlessly reset to same value
00347         assert(
00348             str->type() == STANDARD_TYPE_CHAR
00349             ? (result->storage() == str->storage())
00350             : true);
00351         result->length(
00352             SqlStrAlterCase<1,1,AlterCaseLower>(
00353                 result->pointer(),
00354                 result->storage(),
00355                 str->pointer(),
00356                 str->stringLength()));
00357     }
00358 }

void strToUpperA ( RegisterRef< char * > *  result,
RegisterRef< char * > *  str 
)

ToUpper.

Ascii.

May throw "22001".

Definition at line 361 of file ExtString.cpp.

References RegisterRef< TMPLT >::isNull(), StandardTypeDescriptor::isTextArray(), RegisterRef< TMPLT >::length(), RegisterRef< TMPLT >::pointer(), STANDARD_TYPE_CHAR, RegisterRef< TMPLT >::storage(), RegisterRef< TMPLT >::stringLength(), RegisterRef< TMPLT >::toNull(), and RegisterReference::type().

Referenced by ExtStringRegister().

00364 {
00365     assert(StandardTypeDescriptor::isTextArray(str->type()));
00366     assert(str->type() == result->type());
00367 
00368     // toupper to a null results in null
00369     if (result->isNull() || str->isNull()) {
00370         result->toNull();
00371         result->length(0);
00372     } else {
00373         assert(
00374             str->type() == STANDARD_TYPE_CHAR
00375             ? (result->storage() == str->storage())
00376             : true);
00377         // fixed width case: length should be harmlessly reset to same value
00378         result->length(
00379             SqlStrAlterCase<1,1,AlterCaseUpper>(
00380                 result->pointer(),
00381                 result->storage(),
00382                 str->pointer(),
00383                 str->stringLength()));
00384     }
00385 }

void strTrimA ( RegisterRef< char * > *  result,
RegisterRef< char * > *  str,
RegisterRef< char * > *  trimchar,
RegisterRef< int32_t > *  trimLeft,
RegisterRef< int32_t > *  trimRight 
)

Trim.

By Reference. Ascii.

May throw "22001".

Definition at line 389 of file ExtString.cpp.

References RegisterRef< TMPLT >::isNull(), StandardTypeDescriptor::isTextArray(), RegisterRef< TMPLT >::length(), RegisterRef< TMPLT >::pointer(), STANDARD_TYPE_VARCHAR, RegisterRef< TMPLT >::stringLength(), RegisterRef< TMPLT >::toNull(), RegisterReference::type(), and RegisterRef< TMPLT >::value().

Referenced by ExtStringRegister().

00395  {
00396     assert(StandardTypeDescriptor::isTextArray(str->type()));
00397     assert(result->type() == STANDARD_TYPE_VARCHAR);
00398     assert(StandardTypeDescriptor::isTextArray(trimchar->type()));
00399 
00400     // trim to a null results in null
00401     if (result->isNull() || str->isNull() || trimchar->isNull() ||
00402         trimLeft->isNull() || trimRight->isNull()) {
00403         result->toNull();
00404         result->length(0);
00405     } else {
00406         // Don't try anything fancy with RegisterRef accessors. KISS.
00407         char * ptr = result->pointer(); // preserve old value if possible
00408 
00409         if (trimchar->stringLength() != 1) {
00410             // SQL99 Part 2 Section 6.18 General Rule 8.d) Data
00411             // Exception - Trim Error
00412             throw "22027";
00413         }
00414         // Note: This routine is for ASCII only, so the following is OK.
00415         char tc = *(trimchar->pointer());
00416 
00417         // Use trim by reference function:
00418         // TODO: Not sure why cast from char* to char const * is
00419         // required below.
00420         int32_t newLen = SqlStrTrim<1,1>(
00421             const_cast<char const **>(&ptr),
00422             str->pointer(),
00423             str->stringLength(),
00424             trimLeft->value(),
00425             trimRight->value(),
00426             tc);
00427         result->pointer(ptr, newLen);
00428     }
00429 }


Generated on Mon Jun 22 04:00:22 2009 for Fennel by  doxygen 1.5.1