Db_Record::~Db_Record (void) { Record_Size (0); if (Nested ()) { Nest (!Nest ()); Record_Size (0); } }
void Db_Record::Reset_Buffers (void) { if (record_format == BINARY || record_format == FIXED_COLUMN) { record.Max_Size (0); if (Nest () == NESTED) { nest_rec.Max_Size (0); } } else { record.Max_Size (4094); if (Nest () == NESTED) { nest_rec.Max_Size (4094); } } }
void Db_Record::Record_Format (Format_Type format) { if (format == DEFAULT_FORMAT) { format = (Format_Type) Default_Format (); } record_format = format; switch (record_format) { case DBASE: record_format = FIXED_COLUMN; break; case COMMA_DELIMITED: delimiters = comma_delimiter; break; case SPACE_DELIMITED: delimiters = space_delimiter; break; case VERSION3: record_format = TAB_DELIMITED; case TAB_DELIMITED: delimiters = tab_delimiter; break; case SQLITE3: record_format = BINARY; break; default: //---- CSV ---- delimiters = csv_delimiter; break; } if (record_format == BINARY || record_format == FIXED_COLUMN) { Record_Size (0); if (Nested ()) { Nest (!Nest ()); Record_Size (0); } } else { Record_Size (4080); if (Nested ()) { Nest (!Nest ()); Record_Size (4080); } } }
bool Link_Delay_File::Create_Fields (void) { Add_Field ("LINK", DB_INTEGER, 10); Add_LinkDir_Field (); if (type_flag) { Add_Field ("TYPE", DB_INTEGER, 1); } Add_Field ("START", DB_TIME, TIME_FIELD_SIZE, Time_Format ()); Add_Field ("END", DB_TIME, TIME_FIELD_SIZE, Time_Format ()); Add_Field ("FLOW", DB_DOUBLE, 9.2, flow_units); Add_Field ("TIME", DB_TIME, 8.1, SECONDS); if (turn_flag) { Nest (NESTED); Header_Lines (2); Add_Field ("NCONNECT", DB_INTEGER, 2); Add_Field ("OUT_LINK", DB_INTEGER, 10, NO_UNITS, false, NESTED); Add_Field ("OUT_FLOW", DB_DOUBLE, 9.2, flow_units, false, NESTED); Add_Field ("OUT_TIME", DB_TIME, 8.1, SECONDS, false, NESTED); } else { Nest (NO_NEST); Header_Lines (1); } return (Set_Field_Numbers ()); }
bool Db_File::Write (bool nested) { if (!nested && Nest () == FLATTEN) return (true); Nested (nested); return (Write ()); }
Db_Field (string name, Field_Type type, int offset = 0, double size = 0, Units_Type units = NO_UNITS, Nest_Type nest = NO_NEST) { Name (name); Type (type); Offset (offset); Size (size); Units (units); Nest (nest); }
void Parser::Do() { while(lex != t_eof && lex != '}') { Line(); if(Key(tk_using)) { while(!Key(';')) ++lex; } else if(Key(tk_extern) && lex == t_string) { ++lex; ++lex; if(Key('{')) { Do(); Key('}'); } Key(';'); } else if(Key(tk_template)) { if(lex.IsId() || lex == tk_class && lex.IsId(1)) { Key(tk_class); for(;;) { if(lex.IsId()) lex.GetId(); else if(!Key(t_dblcolon)) break; } TemplateParams(); Key(';'); } else { String tnames; String tparam = TemplateParams(tnames); if(!Nest(tparam, tnames)) { Array<Decl> r = Declaration(true, true); for(int i = 0; i < r.GetCount(); i++) { Decl& d = r[i]; d.natural = "template" + tparam + ' ' + d.natural; if(context.access != PRIVATE && !d.isfriend && d.function) { CppItem& im = Item(context.nameing, context.nesting, d.natural); im.name = d.name; im.access = context.access; im.header = Purify(d.header); im.ender = Purify(d.ender); im.kind = context.nesting.IsEmpty() ? FUNCTIONTEMPLATE : d.s_static ? CLASSFUNCTIONTEMPLATE : INSTANCEFUNCTIONTEMPLATE; for(int i = 0; i < d.param.GetCount(); i++) { ScAdd(im.param, d.param[i].natural); ScAdd(im.pname, d.param[i].name); } im.tname = tnames; im.tparam = CleanTp(tparam); } } EatBody(); Key(';'); } } } else if(lex == tk_enum && (lex[1] == '{' || lex[2] == '{')) { ++lex; String name; if(lex.IsId()) name = lex.GetId(); String param; String pname; String n = "enum " + name + " { "; Key('{'); for(;;) { String val; Check(lex.IsId(), "Expected identifier"); String nm = lex.GetId(); if(Key('=')) val = Constant(); if(!param.IsEmpty()) n << ", "; n << nm; ScAdd(param, nm + " = " + val); ScAdd(pname, nm); Key(','); if(Key('}')) break; } n << " }"; CppItem& im = Item(context.nameing, context.nesting, n); im.kind = ENUM; im.name = name; im.access = context.access; im.param = param; im.pname = pname; if(lex.IsId()) im.name = lex.GetId(); CheckKey(';'); } else if(Key('#')) { String n = lex.GetText(); CppItem& im = Item(context.nameing, context.nesting, n); im.kind = MACRO; im.name.Clear(); const char *s = n; while(*s && iscid(*s)) im.name.Cat(*s++); s = strchr(n, '('); if(s) { s++; String p; for(;;) { if(iscid(*s)) p.Cat(*s++); else { ScAdd(im.pname, p); p.Clear(); if(*s == ')' || *s == '\0') break; s++; } } } im.access = context.access; } else if(!Nest(String(), String())) { if(Key(tk_public)) { context.access = PUBLIC; Key(':'); } else if(Key(tk_private)) { context.access = PRIVATE; Key(':'); } else if(Key(tk_protected)) { context.access = PROTECTED; Key(':'); } else { const char *p = lex.Pos(); Array<Decl> r = Declaration(true, true); bool body = EatBody(); for(int i = 0; i < r.GetCount(); i++) { Decl& d = r[i]; if(context.access != PRIVATE && !d.isfriend || d.isfriend && body) { CppItem& im = Item(context.nameing, context.nesting, d.natural); im.name = d.name; im.header = Purify(d.header); im.ender = Purify(d.ender); im.access = context.access; if(d.function) { im.kind = d.istructor ? (d.isdestructor ? DESTRUCTOR : CONSTRUCTOR) : d.isfriend ? INLINEFRIEND : context.nesting.IsEmpty() ? FUNCTION : d.s_static ? CLASSFUNCTION : INSTANCEFUNCTION; for(int i = 0; i < d.param.GetCount(); i++) { ScAdd(im.param, d.param[i].natural); ScAdd(im.pname, d.param[i].name); } } else im.kind = d.type_def ? TYPEDEF : context.nesting.IsEmpty() ? VARIABLE : d.s_static ? CLASSVARIABLE : INSTANCEVARIABLE; } } EatBody(); Key(';'); } } } }
/** \fn parseOneMeta */ bool flvHeader::parseOneMeta(const char *stri,uint64_t endPos,bool &end) { static int nesting=0; nesting++; int type=read8(); Nest(); printf("\n>> type :%d ",type); aprintf("nesting = %d, at %d, : ,end=%d",nesting,ftello(_fd),endPos); switch(type) { case AMF_DATA_TYPE_OBJECT_END: Nest(); printf("** Object end**.\n"); if(ftello(_fd)>=endPos-4) { fseek(_fd,endPos,SEEK_SET); } end=true; nesting--; break; case AMF_DATA_TYPE_OBJECT: { printf("\n"); bool myEnd=false; while(ftello(_fd)<endPos-4 && myEnd==false) { Nest();aprintf("Pos = %d, end=%d (object)\n",ftello(_fd),endPos-4); char *o=readFlvString(); Nest(); printf("\t ** Object**:%s",o); if(false==parseOneMeta(o,endPos,myEnd)) return false; /* char objType=read8(); printf("-->%d",objType); if(objType!=10) { ADM_warning("type is not strict array\n"); goto xxer; } int count=read32(); printf(", count=%d\n",count); for(int i=0;i<count;i++) { if(false==parseOneMeta(endPos)) return false; } break; */ } break; } case AMF_DATA_TYPE_ARRAY: { uint32_t len=read32(); Nest();printf("\n**[FLV] Array : %"PRIu32" entries**\n",len); bool theend; for(int i=0;i<len && ftello(_fd)<endPos-4;i++) if(false==parseOneMeta("",endPos,theend)) return false; Nest();printf("\n"); break; } case AMF_DATA_TYPE_DATE: Skip(8+2);break; case AMF_DATA_TYPE_NUMBER: { float val; uint64_t hi,lo; hi=read32();lo=read32(); hi=(hi<<32)+lo; val=(float)av_int2dbl(hi); printf("->%f",val); setProperties(stri,val); } ;break; case AMF_DATA_TYPE_STRING: { int r=read16(); #if 1 Nest();printf("<"); for(int i=0;i<r;i++) { printf("%c",read8()); } printf(">"); #else Skip(r);} #endif } break; case AMF_DATA_TYPE_BOOL: read8();break; case AMF_DATA_TYPE_MIXEDARRAY: { read32(); while(ftello(_fd)<endPos-4) { char *o=readFlvString(); bool theend; if(!o) break; Nest();printf("** MixedArray:%s **",o); if(false==parseOneMeta(o,endPos,theend)) return false; } if(read8()!=AMF_END_OF_OBJECT) return false; } break; default : printf("Unknown type=%d\n",type);ADM_assert(0); }