Field, Record, and Buffer - PowerPoint PPT Presentation

1 / 18
About This Presentation
Title:

Field, Record, and Buffer

Description:

the smallest logically meaningful unit of information. array : many copies of a single field ... Need padding up to a fixed length. padding character : space ... – PowerPoint PPT presentation

Number of Views:64
Avg rating:3.0/5.0
Slides: 19
Provided by: csSung
Category:
Tags: buffer | field | padding | record

less

Transcript and Presenter's Notes

Title: Field, Record, and Buffer


1
Field, Record, and Buffer
2
Field and Record
  • Field the basic unit of data
  • a single value
  • the smallest logically meaningful unit of
    information
  • array many copies of a single field
  • record a list of different fields
  • structure
  • objects and their members (in memory)

3
File Structures for Structured Data
  • Field
  • domain
  • Record
  • a list of fields
  • type
  • File
  • a collection of records

4
Stream File
  • A single byte stream
  • no additional information

5
Field Structures
  • Fixed-Length Field
  • the position of each field can be found by simple
    arithmetic
  • disadv.
  • Need padding up to a fixed length
  • padding character space
  • Wasted space in the field having a large amount
    of variability in the length of value
  • Variable-Length Field

6
  • Using a length indicator
  • field length
  • Using a field delimiters
  • choice of the delimiter character
  • keywordValue
  • keyword - field name
  • self-describing structure
  • a good format for dealing with missing fields
  • wastes a log of space (keyword)
  • P124, Figure 4.4 (reading delimited fields)

7
(No Transcript)
8
Record Structures
  • Fixed-Length Record
  • each record contains the same of bytes
  • fixed of fixed-length fields
  • a container to hold variable of variable-length
    fields

9
(No Transcript)
10
  • Variable-Length Record
  • fixed of fields
  • Using a length indicator (record length)
  • most commonly used
  • Using an index
  • each entry of the index points to the beginning
    of a record
  • Using an End-of-Record Mark

11
(No Transcript)
12
How to represent the Record Length
  • p129, Figure 4.7
  • Formats for the record length
  • a n-byte binary integer
  • a character string (using formatted output)
  • p131, Figure 4.9
  • Figure 4.4, for op gtgt of istrstream

13
File Dump
  • UNIX (p132)
  • od -xc filename
  • DOS
  • debug filename
  • - d

14
Buffer Classes
  • Pack and Unpack
  • for Delimited Text Fields
  • see p135, App. E
  • for Length-based Fields
  • see p137, App. E
  • for Fixed-length Fields
  • see p138, App E

15
Buffer Class Hierarchy
16
  • virtual public inheritance
  • included only once in the ancestry
  • Protected Member
  • can be used by methods of derived classes
  • (pure) virtual member
  • there is no implementation in the class
  • abstract class
  • the class having virtual member

17
Pack and Unpack
in file
write
read
in buffer
in object
unpack
char name??? char dept???? char
telno920-7525
pack
18
HW 5
  • Ex 3, 4, 11, 14, 15
  • Programming
  • Ex 16, 22, 23
Write a Comment
User Comments (0)
About PowerShow.com