File: omget.gd

package info (click to toggle)
gap-openmath 11.5.3%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 632 kB
  • sloc: xml: 464; makefile: 10
file content (100 lines) | stat: -rw-r--r-- 3,656 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#############################################################################
##
#W  omget.gd           OpenMath Package         Andrew Solomon
#W                                                     Marco Costantini
##
#Y    Copyright (C) 1999, 2000, 2001, 2006
#Y    School Math and Comp. Sci., University of St.  Andrews, Scotland
#Y    Copyright (C) 2004, 2005, 2006 Marco Costantini
##
##  OMGetObject reads an OpenMath object from an input stream and returns
##  a GAP object. EvalOMString is an analog of EvalString for a string which
##  contains an OpenMath object.
##


#############################################################################
##
#F  OMGetObject( <stream> )
##
##  <#GAPDoc Label="OMGetObject">
##  <ManSection>
##      <Func Name="OMGetObject" Arg="stream" />
##  <Description>
##  <A>stream</A> is an input stream (see 
##  <Ref BookName="ref" Oper="InputTextFile" />, 
##  <Ref BookName="ref" Oper="InputTextUser" />, 
##  <Ref BookName="ref" Oper="InputTextString" />, 
##  <Ref BookName="ref" Oper="InputOutputLocalProcess" />, 
##  <Ref BookName="scscp" Oper="InputOutputTCPStream" Label="for client" />,
##  <Ref BookName="scscp" Oper="InputOutputTCPStream" Label="for server" />)
##  with an &OpenMath; object on it.
##  <Ref Func="OMGetObject" /> takes precisely one object off <A>stream</A> 
##  and returns it as a GAP object.
##  Both XML and binary &OpenMath; encoding are supported: autodetection
##  is used.
##  <P/>
##  This may be used to retrieve objects from a file. In the following
##  example we demonsrate reading the same content in binary and XML
##  formats using the test files supplied with the package (the package
##  autodetects whether binary or XML encoding is used):
##  <Example>
##  <![CDATA[
##  gap> txml:=Filename(DirectoriesPackageLibrary("openmath","tst"),"test3.omt");;   
##  gap> tbin:=Filename(DirectoriesPackageLibrary("openmath","tst"),"test3.bin");;   
##  gap> xstream := InputTextFile( txml );; bstream := InputTextFile( tbin );;   
##  gap> x:=OMGetObject(xstream); y:=OMGetObject(bstream);
##  912873912381273891
##  912873912381273891
##  gap> x:=OMGetObject(xstream); y:=OMGetObject(bstream);
##  E(4)
##  E(4)
##  gap> CloseStream(xstream);CloseStream(bstream);
##  ]]>
##  </Example>
##  To paste an &OpenMath; object directly into standard input
##  execute the following command in GAP:
##  <Log>
##  <![CDATA[
##  gap> s:= InputTextUser();; g := OMGetObject(s); CloseStream(s);
##  gap> 
##  ]]>
##  </Log>
##  <P/> For XML &OpenMath;, this function requires that the &GAP; package 
##  &GAPDoc; is available.
##  </Description>
##  </ManSection>
##  <#/GAPDoc>
DeclareGlobalFunction("OMGetObject");


#############################################################################
##
#F  EvalOMString( <omstr> )
##
##  <#GAPDoc Label="EvalOMString">
##  <ManSection>
##      <Func Name="EvalOMString" Arg="omstr" />
##  <Description>
##  This function is an analog of <Ref Func="EvalString" BookName="ref" />.
##  Its argument <A>omstr</A> must be a string containing a single &OpenMath;
##  object. <Ref Func="EvalOMString"/> will return the &GAP; object represented
##  by <A>omstr</A>. 
##  <P/>
##  If <A>omstr</A> contains more &OpenMath; objects, the rest will be ignored.
##  <Example>
##  <![CDATA[
##  gap> s:="<OMOBJ><OMS cd=\"setname1\" name=\"Z\"/></OMOBJ>";;
##  gap> EvalOMString(s);
##  Integers
##  gap> G:=SL(2,5);; G=EvalOMString(OMString(G));
##  true
##  ]]>
##  </Example>
##  </Description>
##  </ManSection>
##  <#/GAPDoc>
DeclareGlobalFunction("EvalOMString");

#############################################################################
#E