Beispiel #1
0
		public void Read(BinaryReader reader, OcadStIndex index) {
			StType = index.StType;
			ObjIndex = index.ObjIndex;
			reader.BaseStream.Seek(index.Pos, SeekOrigin.Begin);
			char[] chars = reader.ReadChars(index.Len);

			// Count the number of values (number of tabs).
			int nValues = 0;
			int i;
			for (i = 0; i < chars.Length && chars[i] != 0; ++i) {
				if (chars[i] == '\t')
					++nValues;
			}

            codes = new char[nValues];
			values = new string[nValues];

			for (i = 0; i < chars.Length && chars[i] != 0 && chars[i] != '\t'; ++i)
				;
			firstField = new string(chars, 0, i);

			++i;
			int iValue = 0;
			while (i < chars.Length && chars[i] != 0) {
				int start = i;

				while (i < chars.Length && chars[i] != 0 && chars[i] != '\t')
					++i;

				codes[iValue] = chars[start];
				if (i > start)
					values[iValue] = new string(chars, start + 1, i - start - 1);

                ++iValue;

                if (i >= chars.Length || chars[i] == 0)
                    break;

				++i;
			}

            Debug.Assert(iValue == nValues);
		}
Beispiel #2
0
		public void Read(BinaryReader reader, int firstBlock) {
            List<OcadStIndex> indexList = new List<OcadStIndex>();
			int nextBlock = firstBlock;

			while (nextBlock != 0) {
				reader.BaseStream.Seek(nextBlock, SeekOrigin.Begin);
				nextBlock = reader.ReadInt32();
				for (int i = 0; i < 256; ++i) {
					OcadStIndex stindex = new OcadStIndex();
					stindex.Read(reader);
					if (stindex.StType != 0)
						indexList.Add(stindex);
				}
			}

			indexes = indexList.ToArray();
		}