00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #include <LimitStateFunction.h>
00035 #include <Vector.h>
00036 #include <string.h>
00037 #include <classTags.h>
00038
00039 LimitStateFunction::LimitStateFunction( int passedTag,
00040 TCL_Char *passedExpression)
00041 :ReliabilityDomainComponent(passedTag, LIMIT_STATE_FUNCTION)
00042 {
00043 originalExpression = new char[500];
00044 strcpy(originalExpression,passedExpression);
00045
00046 expressionWithAddition = new char[500];
00047 strcpy(expressionWithAddition,passedExpression);
00048
00049 tokenizedExpression = new char[500];
00050 tokenizeIt(passedExpression);
00051 }
00052
00053
00054 LimitStateFunction::~LimitStateFunction()
00055 {
00056 if (originalExpression != 0) {
00057 delete [] originalExpression;
00058 }
00059 if (expressionWithAddition != 0) {
00060 delete [] expressionWithAddition;
00061 }
00062 if (tokenizedExpression != 0) {
00063 delete [] tokenizedExpression;
00064 }
00065 }
00066
00067
00068 void
00069 LimitStateFunction::Print(OPS_Stream &s, int flag)
00070 {
00071 }
00072
00073
00074
00075 char *
00076 LimitStateFunction::getExpression()
00077 {
00078 return expressionWithAddition;
00079 }
00080
00081
00082 char *
00083 LimitStateFunction::getTokenizedExpression()
00084 {
00085 return tokenizedExpression;
00086 }
00087
00088 int
00089 LimitStateFunction::addExpression(char *addition)
00090 {
00091 strcat(expressionWithAddition,addition);
00092
00093 tokenizeIt(expressionWithAddition);
00094
00095 return 0;
00096 }
00097
00098 int
00099 LimitStateFunction::removeAddedExpression()
00100 {
00101 strcpy(expressionWithAddition,originalExpression);
00102
00103 tokenizeIt(expressionWithAddition);
00104
00105 return 0;
00106 }
00107
00108
00109 int
00110 LimitStateFunction::tokenizeIt(TCL_Char *originalExpression)
00111 {
00112
00113 char *lsf_forTokenizing = new char[500];
00114 char separators[5] = "}{";
00115 char *dollarSign = "$";
00116 strcpy(lsf_forTokenizing,originalExpression);
00117 char lsf_expression[500] = "";
00118 char *tokenPtr2 = strtok( lsf_forTokenizing, separators);
00119 while ( tokenPtr2 != NULL ) {
00120 if ( strncmp(tokenPtr2, "a",1) == 0
00121 || strncmp(tokenPtr2, "b",1) == 0
00122 || strncmp(tokenPtr2, "c",1) == 0
00123 || strncmp(tokenPtr2, "d",1) == 0
00124 || strncmp(tokenPtr2, "e",1) == 0
00125 || strncmp(tokenPtr2, "f",1) == 0
00126 || strncmp(tokenPtr2, "g",1) == 0
00127 || strncmp(tokenPtr2, "h",1) == 0
00128 || strncmp(tokenPtr2, "i",1) == 0
00129 || strncmp(tokenPtr2, "j",1) == 0
00130 || strncmp(tokenPtr2, "k",1) == 0
00131 || strncmp(tokenPtr2, "l",1) == 0
00132 || strncmp(tokenPtr2, "m",1) == 0
00133 || strncmp(tokenPtr2, "n",1) == 0
00134 || strncmp(tokenPtr2, "o",1) == 0
00135 || strncmp(tokenPtr2, "p",1) == 0
00136 || strncmp(tokenPtr2, "q",1) == 0
00137 || strncmp(tokenPtr2, "r",1) == 0
00138 || strncmp(tokenPtr2, "s",1) == 0
00139 || strncmp(tokenPtr2, "t",1) == 0
00140 || strncmp(tokenPtr2, "u",1) == 0
00141 || strncmp(tokenPtr2, "v",1) == 0
00142 || strncmp(tokenPtr2, "w",1) == 0
00143 || strncmp(tokenPtr2, "x",1) == 0
00144 || strncmp(tokenPtr2, "y",1) == 0
00145 || strncmp(tokenPtr2, "z",1) == 0) {
00146 strcat(lsf_expression, dollarSign);
00147 strcat(lsf_expression, tokenPtr2);
00148 }
00149 else {
00150 strcat(lsf_expression, tokenPtr2);
00151 }
00152 tokenPtr2 = strtok( NULL, separators);
00153 }
00154 delete [] lsf_forTokenizing;
00155
00156 strcpy(tokenizedExpression,lsf_expression);
00157
00158 return 0;
00159 }