Thank you for you assistance and patients Joe
// This is a bit over my head as I was originally a C programmer and
// I am still way behind on Visual C++
// It's gonna take me a while to get my head into understanding this.
// how do I get buffer(read CIP file) into this parse routine?
// how do I retrieve the parameters?
char * ParseAttributes(char * start, std::map<CStringA, CStringA>
attributes)
{
while(true)
{ /* scan attributes */
if(strncmp(start, CIP3PreviewImage, strlen(CIP3PreviewImage)) == 0)
{ /* at image */
start += strlen(CIP3PreviewImage);
while(*start != '\n')
start++;
return start;
} /* at image */
while(*start != '/')
{ /* scan to next dictionary entry */
start++;
} /* scan to next dictionary entry */
// /Name value def
// ^
// | We are here
char * begin = ++start;
while(*start != ' ')
{ /* scan past keyword */
start++;
} /* scan past keyword */
// /Name value def
// ^ ^
// | |
// begin start
CStringA name(begin, start-begin));
while(isspace(*start)) // skip past whitespace
start++;
char * def = strstr(start, "def");
if(def == NULL)
{ /* def not found */
//... deal with ill-formed expression
return NULL; // or value of your choice, or throw exception
} /* def not found */
def--;
while(isspace(*def))
--def;
CStringA val(start, def-start + 1);
attributes.insert(std::pair(name, val));
while(*def != '\n') // now skip to the EOL
def++;
start = ++def;
} /* scan attributes */
} // ParseAttibutes