public override bool Equals(object obj) { ElementDecl other = obj as ElementDecl; if (other == null) { return(false); } return(Type.Equals(other.Type) && NameInfo.Equals(other.NameInfo)); }
/// <summary> /// Attribute objects are reused during parsing to reduce memory allocations, /// hence the Reset method. /// </summary> public void Reset(string name, XmlNodeType nt, string value) { Value = value; Name = name; NodeType = nt; Space = XmlSpace.None; XmlLang = null; IsEmpty = true; _attributes.Count = 0; DtdType = null; }
private void ProcessElement(FictionBook fictionBook, XmlNode node, List <XmlElement> invalidNodes) { foreach (XmlNode childNode in node.ChildNodes) { ProcessElement(fictionBook, childNode, invalidNodes); } switch (node.NodeType) { case XmlNodeType.Text: string text = node.InnerText; text = bullets.Replace(text, new MatchEvaluator(delegate(Match match) { fictionBook.ModificationType = ModificationType.Text; return("-"); })); text = invalidChars.Replace(text, new MatchEvaluator(delegate(Match match) { fictionBook.ModificationType = ModificationType.Text; return(" "); })); node.InnerText = text; //node.InnerText = invalidChars.Replace(bullets.Replace(node.InnerText, "-"), " "); break; case XmlNodeType.Element: ElementDecl elementDecl = this.fb2Dtd.FindElement(node.LocalName); if (elementDecl == null) { invalidNodes.Add(node as XmlElement); } break; } }
// Add a new element declaration to the namespace internal void AddElementDecl(ElementDecl elmDecl){ Util.Log("URTNamespace.AddElementDecl "); _elmDecls.Add(elmDecl); }
public int GetElementSize(ElementDecl element) { return element.Name.ArraySizeNew * (element.Name.IsPointer ? _ptrLen : element.Type.Length); }
public int GetElementSize(ElementDecl element) { int typeLength = element.NameInfo.IsPointer ? _ptrLen : element.Type.Length; return element.NameInfo.ArrayLength * typeLength; }
public StructDecl(TypeDecl type, ElementDecl[] elements) { Type = type; Elements = elements; }
private void Init(BulletReader reader, bool swap) { if (swap) { throw new NotImplementedException(); } Stream stream = reader.BaseStream; reader.ReadTag("SDNA"); // Element names reader.ReadTag("NAME"); string[] names = reader.ReadStringList(); var nameInfos = names .Select(n => new NameInfo(n)) .ToArray(); _hasIntType = names.Contains("int"); // Types reader.ReadTag("TYPE"); string[] typeNames = reader.ReadStringList(); stream.Position = (stream.Position + 3) & ~3; reader.ReadTag("TLEN"); TypeDecl[] types = typeNames.Select(name => { short length = reader.ReadInt16(); if (_ptrLen == 0 && name == "ListBase") { _ptrLen = length / 2; } return new TypeDecl(name, length); }).ToArray(); stream.Position = (stream.Position + 3) & ~3; // Structs reader.ReadTag("STRC"); int numStructs = reader.ReadInt32(); _structs = new StructDecl[numStructs]; _structByTypeName = new Dictionary<string, StructDecl>(numStructs); for (int i = 0; i < numStructs; i++) { short typeIndex = reader.ReadInt16(); TypeDecl structType = types[typeIndex]; int numElements = reader.ReadInt16(); var elements = new ElementDecl[numElements]; for (int j = 0; j < numElements; j++) { typeIndex = reader.ReadInt16(); short nameIndex = reader.ReadInt16(); elements[j] = new ElementDecl(types[typeIndex], nameInfos[nameIndex]); } var structDecl = new StructDecl(structType, elements); structType.Struct = structDecl; _structs[i] = structDecl; _structByTypeName.Add(structType.Name, structDecl); } }
private void Init(BulletReader reader, bool swap) { if (swap) { throw new NotImplementedException(); } Stream stream = reader.BaseStream; reader.ReadTag("SDNA"); // Element names reader.ReadTag("NAME"); string[] names = reader.ReadStringList(); var nameInfos = names .Select(n => new NameInfo(n)) .ToArray(); _hasIntType = names.Contains("int"); // Types reader.ReadTag("TYPE"); string[] typeNames = reader.ReadStringList(); stream.Position = (stream.Position + 3) & ~3; reader.ReadTag("TLEN"); TypeDecl[] types = typeNames.Select(name => { short length = reader.ReadInt16(); if (_ptrLen == 0 && name == "ListBase") { _ptrLen = length / 2; } return(new TypeDecl(name, length)); }).ToArray(); stream.Position = (stream.Position + 3) & ~3; // Structs reader.ReadTag("STRC"); int numStructs = reader.ReadInt32(); _structs = new StructDecl[numStructs]; _structByTypeName = new Dictionary <string, StructDecl>(numStructs); for (int i = 0; i < numStructs; i++) { short typeIndex = reader.ReadInt16(); TypeDecl structType = types[typeIndex]; int numElements = reader.ReadInt16(); var elements = new ElementDecl[numElements]; for (int j = 0; j < numElements; j++) { typeIndex = reader.ReadInt16(); short nameIndex = reader.ReadInt16(); elements[j] = new ElementDecl(types[typeIndex], nameInfos[nameIndex]); } var structDecl = new StructDecl(structType, elements); structType.Struct = structDecl; _structs[i] = structDecl; _structByTypeName.Add(structType.Name, structDecl); } }
public int GetElementSize(ElementDecl element) { int typeLength = element.NameInfo.IsPointer ? _ptrLen : element.Type.Length; return(element.NameInfo.ArrayLength * typeLength); }
public int GetElementSize(ElementDecl element) { return(element.Name.ArraySizeNew * (element.Name.IsPointer ? _ptrLen : element.Type.Length)); }