📄 cxxmultipleconstraints.c
字号:
} fprintf(src, "};\n\n"); fprintf(src, " sizeList = %d;\n", iSCPresent); fprintf(src, " return &%s_SizeConstraintList[0];\n", e->type->cxxTypeRefInfo->fieldName); } else { fprintf(src, " sizeList = 0;\n"); fprintf(src, " return NULL;\n"); } fprintf (src, "}\n\n\n"); if(bAlphafound == 1) { fprintf (hdr, " const char* PermittedAlphabet(int &sizePermittedAlpha)const;\n\n"); fprintf (src, "const char* \n"); if(i == 1 || i == 3) { fprintf(src, "%s::", definedName); } fprintf(src, "%s::PermittedAlphabet(int &sizePermittedAlpha)const\n", className); fprintf (src, "{\n"); fprintf(src, "\n"); fprintf(src, " static const char alpha[] = {%s};\n", cAlpha); fprintf(src, " sizePermittedAlpha = %d;\n", iAlphasize); fprintf(src, " return alpha;\n"); fprintf (src, "}\n\n\n"); } fprintf (hdr, " %s& operator=(const char* str)\n", className); fprintf (hdr, " { %s::operator=(str); return *this;}\n",e->type->cxxTypeRefInfo->className); fprintf (hdr, " %s& operator=(const std::string& str)\n",className ); fprintf (hdr, " { %s::operator=(str); return *this;}\n",e->type->cxxTypeRefInfo->className); fprintf (hdr, " };\n\n"); if(i!= 3 && i != 0) { /* Last we declare an instance of the internal class we */ /* just created */ if(i==0) { fprintf (hdr, "typedef "); }/*if(i==0)*/ fprintf (hdr, " %s ", className); if (e->type->cxxTypeRefInfo->isPtr) { fprintf (hdr, "*"); }/*if (e->type->cxxTypeRefInfo->isPtr)*/ fprintf (hdr, "%s;\n", e->type->cxxTypeRefInfo->fieldName); fprintf (hdr, "\n\n"); } free(e->type->cxxTypeRefInfo->className); e->type->cxxTypeRefInfo->className = strdup(className); returnvalue=1; break; }/* case BASICTYPE_NUMERIC_STR: *\ * case BASICTYPE_PRINTABLE_STR: * * case BASICTYPE_BMP_STR: * * case BASICTYPE_VISIBLE_STR: * * case BASICTYPE_UNIVERSAL_STR: * * case BASICTYPE_IA5_STR: * \* */ case BASICTYPE_BITSTRING: { Subtype* s_type; Subtype* currS_type=NULL; Subtype* andS_type=NULL; Subtype* fakeList = NULL; AsnListNode* curr; AsnListNode* and_curr; int iSCPresent = 0; int count = 0; int iSCLowerBound = 0; int iSCUpperBound = 0; SizeConstraint scList[15]; /*print the generic header for the generated class*/ fprintf (hdr, "class %s %s: public %s {\n", pszGlobalExport, className, e->type->cxxTypeRefInfo->className); s_type = e->type->subtypes; if(s_type->choiceId==SUBTYPE_AND) { and_curr=s_type->a.and->first; while(and_curr) { andS_type=and_curr->data; if(andS_type->choiceId == SUBTYPE_OR) { curr=andS_type->a.or->first; iSCPresent = BasicTypeString_LISTS(hdr, src, scList, iSCPresent, curr, currS_type); } else if(andS_type->choiceId == SUBTYPE_SINGLE) { fakeList = MT(Subtype); fakeList->choiceId = SUBTYPE_OR; APPEND(andS_type, fakeList->a.or); curr = fakeList->a.or->first; iSCPresent = BasicTypeString_LISTS(hdr, src, scList, iSCPresent, curr, currS_type); } and_curr=and_curr->next; } } else if(s_type->choiceId == SUBTYPE_OR) { curr=s_type->a.or->first; iSCPresent = BasicTypeString_LISTS(hdr, src, scList, iSCPresent, curr, currS_type); } else if(s_type->choiceId == SUBTYPE_SINGLE) { fakeList = MT(Subtype); fakeList->choiceId = SUBTYPE_OR; APPEND(s_type, fakeList->a.or); curr = fakeList->a.or->first; iSCPresent = BasicTypeString_LISTS(hdr, src, scList, iSCPresent, curr, currS_type); } fprintf(hdr, " public:\n"); fprintf(hdr, " %s (const char *stringForm=NULL):AsnBits(stringForm){ }\n", className); fprintf(hdr, " %s (size_t numBits):AsnBits(numBits) { }\n", e->type->cxxTypeRefInfo->fieldName); fprintf(hdr, " %s (const unsigned char *bitOcts, size_t numBits):AsnBits(bitOcts, numBits){ }\n", className); fprintf(hdr, " %s (const %s &_b):AsnBits(_b){ }\n", className, className); fprintf (hdr, " const SizeConstraint* SizeConstraints(int &sizeList)const;\n\n"); fprintf (src, "const SizeConstraint* \n"); if(i == 1 || i == 3) { fprintf(src, "%s::", definedName); } fprintf(src, "%s::SizeConstraints(int &sizeList)const\n", className); fprintf (src, "{\n"); if(iSCPresent > 0 ) { count = 0; if(scList[count].upperBoundExists == 1 && scList[count].upperBound > iSCUpperBound) { iSCUpperBound = scList[count].upperBound; } if(scList[count].upperBoundExists == 0 && scList[count].lowerBound > iSCUpperBound) { iSCUpperBound = scList[count].lowerBound; } if(scList[count].lowerBound < iSCLowerBound) { iSCLowerBound = scList[count].lowerBound; } while(count < iSCPresent) { if(scList[count].upperBoundExists == 2) { iSCPresent = 0; } count++; } } if(iSCPresent > 0 ) { fprintf(src, " static const SizeConstraint %s_SizeConstraintList[] = \n {", e->type->cxxTypeRefInfo->fieldName); for(count = 0; count < iSCPresent; count++) { fprintf(src, "{ %ld, %ld, %d }", scList[count].lowerBound, scList[count].upperBound, scList[count].upperBoundExists); if(count + 1 < iSCPresent) { fprintf(src, ",\n "); } } fprintf(src, "};\n\n"); fprintf(src, " sizeList = %d;\n", iSCPresent); fprintf(src, " return &%s_SizeConstraintList[0];\n", e->type->cxxTypeRefInfo->fieldName); } else { fprintf(src, " sizeList = 0;\n"); fprintf(src, " return NULL;\n"); } fprintf (src, "}\n\n\n"); fprintf (hdr, " %s & operator=(const char *stringForm){ SetEqual(stringForm); return *this; }\n", className); fprintf (hdr, " };\n\n"); if (i != 3 && i != 0) { /* Last we declare an instance of the internal class we */ /* just created */ if(i==0) { fprintf (hdr, "typedef "); }/*if(i==0)*/ fprintf (hdr, " %s ", className); if (e->type->cxxTypeRefInfo->isPtr) { fprintf (hdr, "*"); }/*if (e->type->cxxTypeRefInfo->isPtr)*/ fprintf (hdr, "%s;\n", e->type->cxxTypeRefInfo->fieldName); fprintf (hdr, "\n\n"); } free(e->type->cxxTypeRefInfo->className); e->type->cxxTypeRefInfo->className = strdup(className); returnvalue=1; break; } /* case BASICTYPE_BITSTRING: */ case BASICTYPE_OCTETSTRING: { Subtype* s_type; Subtype* currS_type=NULL; Subtype* andS_type=NULL; Subtype* fakeList = NULL; AsnListNode* curr; AsnListNode* and_curr; int iSCPresent = 0; int count = 0; int iSCLowerBound = 0; int iSCUpperBound = 0; SizeConstraint scList[15]; /*print the generic header for the generated class*/ fprintf (hdr, "class %s %s: public %s {\n", pszGlobalExport, className, e->type->cxxTypeRefInfo->className); s_type = e->type->subtypes; if(s_type->choiceId==SUBTYPE_AND) { and_curr=s_type->a.and->first; while(and_curr) { andS_type=and_curr->data; if(andS_type->choiceId == SUBTYPE_OR) { curr=andS_type->a.or->first; iSCPresent = BasicTypeString_LISTS(hdr, src, scList, iSCPresent, curr, currS_type); } else if(andS_type->choiceId == SUBTYPE_SINGLE) { fakeList = MT(Subtype); fakeList->choiceId = SUBTYPE_OR; APPEND(andS_type, fakeList->a.or); curr = fakeList->a.or->first; iSCPresent = BasicTypeString_LISTS(hdr, src, scList, iSCPresent, curr, currS_type); } and_curr=and_curr->next; } } else if(s_type->choiceId == SUBTYPE_OR) { curr=s_type->a.or->first; iSCPresent = BasicTypeString_LISTS(hdr, src, scList, iSCPresent, curr, currS_type); } else if(s_type->choiceId == SUBTYPE_SINGLE) { fakeList = MT(Subtype); fakeList->choiceId = SUBTYPE_OR; APPEND(s_type, fakeList->a.or); curr = fakeList->a.or->first; iSCPresent = BasicTypeString_LISTS(hdr, src, scList, iSCPresent, curr, currS_type); } fprintf (hdr, " public:\n"); fprintf (hdr, " %s ():AsnOcts() { }\n", className); fprintf (hdr, " %s (const char *str):AsnOcts(str) { }\n", className); fprintf (hdr, " %s (const char *str, const size_t len):AsnOcts(str, len) { }\n", className); fprintf (hdr, " %s (const %s &o):AsnOcts(o){ }\n", className, className); fprintf (hdr, " const SizeConstraint* SizeConstraints(int &sizeList)const;\n\n"); fprintf (src, "const SizeConstraint* \n"); if(i == 1 || i == 3) { fprintf(src, "%s::", definedName); } fprintf(src, "%s::SizeConstraints(int &sizeList)const\n", className); fprintf (src, "{\n"); if(iSCPresent > 0 ) { count = 0; if(scList[count].upperBoundExists == 1 && scList[count].upperBound > iSCUpperBound) { iSCUpperBound = scList[count].upperBound; } if(scList[count].upperBoundExists == 0 && scList[count].lowerBound > iSCUpperBound) { iSCUpperBound = scList[count].lowerBound; } if(scList[count].lowerBound < iSCLowerBound) { iSCLowerBound = scList[count].lowerBound; } while(count < iSCPresent) { if(scList[count].upperBoundExists == 2) { iSCPresent = 0; } count++; } } if(iSCPresent > 0 ) { fprintf(src, " static const SizeConstraint %s_SizeConstraintList[] = \n {", e->type->cxxTypeRefInfo->fieldName); for(count = 0; count < iSCPresent; count++) { fprintf(src, "{ %ld, %ld, %d }", scList[count].lowerBound, scList[count].upperBound, scList[count].upperBoundExists); if(count + 1 < iSCPresent) { fprintf(src, ",\n "); } } fprintf(src, "};\n\n"); fprintf(src, " sizeList = %d;\n", iSCPresent); fprintf(src, " return &%s_SizeConstraintList[0];\n", e->type->cxxTypeRefInfo->fieldName); } else { fprintf(src, " sizeList = 0;\n"); fprintf(src, " return NULL;\n"); } fprintf (src, "}\n\n\n"); fprintf (hdr, " %s &operator = (const AsnOcts &o)\n", className); fprintf (hdr, " { SetEqual(o); return *this;}\n"); fprintf (hdr, " %s &operator = (const char *str)\n", className); fprintf (hdr, " { SetEqual(str); return *this; }\n"); fprintf (hdr, " };\n\n"); if(i != 3 && i != 0) { /* Last we declare an instance of the internal class we */ /* just created */ if(i==0) { fprintf (hdr, "typedef "); }/*if(i==0)*/ fprintf (hdr, " %s ", className); if (e->type->cxxTypeRefInfo->isPtr) { fprintf (hdr, "*"); }/*if (e->type->cxxTypeRefInfo->isPtr)*/ fprintf (hdr, "%s;\n", e->type->cxxTypeRefInfo->fieldName); fprintf (hdr, "\n\n"); } free(e->type->cxxTypeRefInfo->className); e->type->cxxTypeRefInfo->className = strdup(className); returnvalue=1; break; }/* case BASICTYPE_OCETSTRING: */ default: { returnvalue = 0; break; }/*default*/ }/*switch(e->type->basicType->choiceId)*/ free(className); return returnvalue; }/*int PrintCxxMultiConstraintOrHandler*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -