From 6ba98a9f9f48e13738d9736cba9c45b5e94f42f2 Mon Sep 17 00:00:00 2001 From: Brian Cully Date: Mon, 14 Apr 2008 21:52:55 -0400 Subject: Initial import --- libconfig/.svn/text-base/Parser.m.svn-base | 95 ++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 libconfig/.svn/text-base/Parser.m.svn-base (limited to 'libconfig/.svn/text-base/Parser.m.svn-base') diff --git a/libconfig/.svn/text-base/Parser.m.svn-base b/libconfig/.svn/text-base/Parser.m.svn-base new file mode 100644 index 0000000..f95cb3d --- /dev/null +++ b/libconfig/.svn/text-base/Parser.m.svn-base @@ -0,0 +1,95 @@ +#include "Parser.h" +#include "ArrayData.h" +#include "DictData.h" +#include "NumData.h" +#include "StringData.h" +#include "String.h" + +#include +#include +#include +#include + +@implementation Parser +-(int) +getLineLenFrom: (const char *)startAddr to: (const char *)endAddr +{ + int len; + char quote = '\0'; + int frenchBraces = 0, squareBraces = 0; + + for (len = 0; startAddr+len < endAddr; len++) { + if (!quote && !frenchBraces && !squareBraces && + *(startAddr+len) == ';') + break; + + switch (*(startAddr+len)) { + case '{': + frenchBraces++; + break; + case '}': + if (!frenchBraces) + fprintf(stderr, + "WARNING: found `}' without `{'.\n"); + else + frenchBraces--; + break; + case '[': + squareBraces++; + break; + case ']': + if (!squareBraces) + fprintf(stderr, + "WARNING: found ']' without '['.\n"); + else + squareBraces--; + break; + case '"': + if (!quote) + quote = *(startAddr+len); + else + quote = '\0'; + break; + } + } + + return len; +} + +-init +{ + return self; +} + +-free +{ + return [super free]; +} + +-(DataObject *) +getDataFrom: (String *)dataStr +{ + const char *dataBuff; + id dataElem; + + dataBuff = [dataStr getStr]; + + /* Figure out what type of node to allocate. */ + switch (dataBuff[0]) { + case '{': + dataElem = [[DictData new] init]; + break; + case '[': + dataElem = [[ArrayData new] init]; + break; + case '"': + dataElem = [[StringData new] init]; + break; + default: + dataElem = [[NumData new] init]; + break; + } + + return [dataElem setFromBuffer: dataBuff withLength: [dataStr getLen]]; +} +@end -- cgit v1.2.3