public RosArray(RosType type) : base(string.Format("array<{0}>", type)) { if (type == null) throw new ArgumentNullException("type"); this.type = type; }
RosField(RosType type, string name) { if (type == null) throw new ArgumentNullException("type"); if (name == null) throw new ArgumentNullException("name"); this.type = type; this.name = name; }
public static RosField Parse(Queue<string> lines) { string[] declarationDetails = lines.Dequeue().Split(' '); IEnumerable<string> members = lines.Dequeue(line => line.Length >= 2 && line.Substring(0, 2) == " ").Select(line => line.Substring(2)); string typeName = declarationDetails[0]; bool isArray = typeName.EndsWith("[]"); if (isArray) typeName = typeName.Substring(0, typeName.Length - 2); string fieldName = declarationDetails[1]; RosType type; if (members.Any() || !RosType.BasicTypes.Any(basicType => basicType.Name == typeName)) type = new RosStruct(typeName, members); else type = RosType.BasicTypes.Single(basicType => basicType.Name == typeName); if (fieldName.Contains("=")) type = new RosConstant(type); if (isArray) type = new RosArray(type); return new RosField(type, fieldName); }
public RosConstant(RosType type) : base(string.Format("constant<{0}>", type)) { if (type == null) throw new ArgumentNullException("type"); }