Create a Format based on an IMessageMetadata.
| 56 | |
| 57 | // Create a Format based on an IMessageMetadata. |
| 58 | Format* Routine::createFormat(MemoryPool& pool, IMessageMetadata* params, bool addEof) |
| 59 | { |
| 60 | FbLocalStatus status; |
| 61 | |
| 62 | unsigned count = params->getCount(&status); |
| 63 | status.check(); |
| 64 | |
| 65 | Format* format = Format::newFormat(pool, count * 2 + (addEof ? 1 : 0)); |
| 66 | unsigned runOffset = 0; |
| 67 | |
| 68 | dsc* desc = format->fmt_desc.begin(); |
| 69 | |
| 70 | for (unsigned i = 0; i < count; ++i) |
| 71 | { |
| 72 | unsigned descOffset, nullOffset, descDtype, descLength; |
| 73 | |
| 74 | unsigned type = params->getType(&status, i); |
| 75 | status.check(); |
| 76 | unsigned len = params->getLength(&status, i); |
| 77 | status.check(); |
| 78 | runOffset = fb_utils::sqlTypeToDsc(runOffset, type, len, &descDtype, &descLength, |
| 79 | &descOffset, &nullOffset); |
| 80 | |
| 81 | desc->clear(); |
| 82 | desc->dsc_dtype = descDtype; |
| 83 | desc->dsc_length = descLength; |
| 84 | desc->dsc_scale = params->getScale(&status, i); |
| 85 | status.check(); |
| 86 | desc->dsc_sub_type = params->getSubType(&status, i); |
| 87 | status.check(); |
| 88 | desc->setTextType(params->getCharSet(&status, i)); |
| 89 | status.check(); |
| 90 | desc->dsc_address = (UCHAR*)(IPTR) descOffset; |
| 91 | desc->dsc_flags = (params->isNullable(&status, i) ? DSC_nullable : 0); |
| 92 | status.check(); |
| 93 | |
| 94 | ++desc; |
| 95 | desc->makeShort(0, (SSHORT*)(IPTR) nullOffset); |
| 96 | |
| 97 | ++desc; |
| 98 | } |
| 99 | |
| 100 | if (addEof) |
| 101 | { |
| 102 | // Next item is aligned on USHORT, so as the previous one. |
| 103 | desc->makeShort(0, (SSHORT*)(IPTR) runOffset); |
| 104 | runOffset += sizeof(USHORT); |
| 105 | } |
| 106 | |
| 107 | format->fmt_length = runOffset; |
| 108 | |
| 109 | return format; |
| 110 | } |
| 111 | |
| 112 | void Routine::setStatement(Statement* value) |
| 113 | { |
nothing calls this directly
no test coverage detected