DIRECTORY Atom, DB, DBEnvironment, DBNames, Rope; DBNamesImpl: CEDAR PROGRAM IMPORTS Atom, Rope, DB, DBEnvironment EXPORTS DBNames = BEGIN OPEN Rope, DB; Separator: PUBLIC CHAR _ '#; Sep: ROPE = Rope.FromChar[Separator]; EntityToName: PUBLIC PROC[e: Entity, seg: DB.Segment] RETURNS[ name: ROPE ] = { name _ Rope.Cat[DB.GetSegmentInfo[seg].filePath, Sep, Atom.GetPName[seg], Sep]; name _ Rope.Cat[ name, NameOf[DomainOf[e]], Sep, NameOf[e] ] }; MakeName: PUBLIC PROC[seg: DB.Segment, domain, eName: ROPE] RETURNS[name: ROPE] = { name _ Rope.Cat[GetSegmentInfo[seg].filePath, Sep, Atom.GetPName[seg], Sep]; name _ Rope.Cat[ name, domain, Sep, eName ] }; NameToEntity: PUBLIC PROC[name: ROPE, create: BOOL _ FALSE] RETURNS[e: Entity] = { segName, domainName, entityName: ROPE; domain: Domain; segment: DB.Segment; [segName, domainName, entityName] _ DecomposeName[name]; segment _ Atom.MakeAtom[segName]; IF NOT Rope.Equal[DB.GetSegmentInfo[segment].filePath, SegmentOf[name].filePath, FALSE] THEN RETURN[NIL]; domain _ DeclareDomain[ domainName, segment, Version[OldOnly] ! DBEnvironment.Error => CHECKED { domain _ NIL; CONTINUE } ]; e _ IF domain = NIL THEN NIL ELSE FetchEntity[ domain, entityName, segment ]; IF e = NIL AND domain # NIL AND create THEN e _ DeclareEntity[ domain, entityName ! DB.Error => CONTINUE ] }; SegmentOf: PUBLIC PROC[name: ROPE] RETURNS[segment: DB.Segment, filePath: ROPE] = { segmentName: ROPE; substrLength: INT _ Rope.Find[name, Sep]; -- always has the length to the next separator filePath _ Rope.Substr[name, 0, substrLength]; name _ Rope.Replace[name, 0, substrLength+1]; -- make sure to throw away the separator substrLength _ Rope.Find[name, Sep]; segmentName _ Rope.Substr[name, 0, substrLength]; RETURN[ Atom.MakeAtom[segmentName], filePath ] }; DecomposeName: PUBLIC PROC[name: ROPE] RETURNS[segment, domain, entity: ROPE] = BEGIN substrLength: INT _ Rope.Find[name, Sep]; name _ Rope.Replace[name, 0, substrLength+1]; substrLength _ Rope.Find[name, Sep]; segment _ Rope.Substr[name, 0, substrLength]; name _ Rope.Replace[name, 0, substrLength+1]; substrLength _ Rope.Find[name, Sep]; domain _ Rope.Substr[name, 0, substrLength]; entity _ Rope.Replace[name, 0, substrLength+1] END; END. . . "File: DBNamesImpl.mesa last edited by: Cattell, July 5, 1983 5:00 pm Donahue, July 13, 1984 5:41:40 pm PDT Willie-sue, February 22, 1983 4:08 pm check to make sure that this is the right segment for the entity throw away the leading file path information now get the remaining fields ÊŘJšœ™šœ™Jšœ™Jšœ%™%Jšœ%™%J˜—šÏk ˜ J˜Jšœ˜J˜J˜J˜J˜—šœ œ˜Jšœ œ˜%J˜Jšœ ˜J˜Jšœœœ˜J˜Jšœ œœ˜J˜Jšœœ˜%J˜š Ïn œœœœ œœ˜OJšœœ=˜OJšœ?˜?J˜—Jšžœœœœœœœ˜QJšœN˜NJšœ0˜0J˜šž œœœœ œœœ˜RJšœ!œ˜&J˜Jšœ œ ˜J˜8J˜!Jšœ@™@šœœ œ=œ˜WJšœœœ˜—˜@Jšœœ œœ˜<—šœœ œœ˜Jšœ,˜0—š œœœ œœ˜+Jšœ(œ œ˜AJ˜——šž œœœœœ œœ˜SJšœ œ˜JšœœÏc.˜XJšœ.˜.Jšœ.Ÿ(˜VJ˜$Jšœ1˜1Jšœ+˜1J˜—š ž œœœœœœ˜OJš˜Jšœœ˜)J™,Jšœ-˜-J™J˜$J˜-Jšœ-˜-J˜$J˜,Jšœ.˜.Jšœ˜J˜——Jšœ˜—…—È ¯