home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / som30tk.zip / som30os2.zip / include / sctmplt.idl < prev    next >
Text File  |  1996-12-24  |  8KB  |  216 lines

  1. //
  2. //   COMPONENT_NAME: some
  3. //
  4. //   ORIGINS: 27
  5. //
  6. //
  7. //    25H7912  (C)  COPYRIGHT International Business Machines Corp. 1992,1994,1996 
  8. //   All Rights Reserved
  9. //   Licensed Materials - Property of IBM
  10. //   US Government Users Restricted Rights - Use, duplication or
  11. //   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  12. //
  13. //#  @(#) somc/sctmplt.idl 2.10 5/9/96 15:31:32 [12/24/96 07:39:44]
  14.  
  15.  
  16. #ifndef sctmplt_idl
  17. #define sctmplt_idl
  18.  
  19. #include <somobj.idl>
  20. interface SOMStringTableC;
  21.  
  22. enum somtCommentStyleT { somtDashesE, somtCPPE, somtCSimpleE, somtCBlockE };
  23.  
  24. interface SOMTTemplateOutputC : SOMObject
  25. {
  26.   const long MAX_INPUT_LINE_LENGTH = 1024;
  27.   const long MAX_OUTPUT_LINE_LENGTH = 4096;
  28.   attribute somtCommentStyleT somtCommentStyle;
  29.   
  30.   // Controls the style in which comments are wrtten as follows:
  31.   //   somtDashesE: "--" at the start of each line
  32.   //   somtCPPE: C++ style, "//" at the start of each line
  33.   //   somtCSimpleE: simple C style, each line wrapped in / * and * /
  34.   //   somtCBlockE: block C style, block style, ie leading / * then a * on each
  35.   //              line and then a final * /
  36.  
  37.   attribute long somtLineLength;
  38.   
  39.   // Controls list output only.  Default is 72.
  40.   // At least one list item will be output on each line, so making
  41.   // this value very short will cause list items to be placed on
  42.   // separate lines.
  43.  
  44.   attribute boolean somtCommentNewline;
  45.   string somtGetSymbol(in string name);
  46.   
  47.   // Returns the value associated with <name>.  If no value is
  48.   // associated with <name> then NULL is returned
  49.  
  50.   void somtSetSymbol(in string name, 
  51.                     in string value);
  52.   
  53.   // Makes the symbol with name <name> have value <value>.  This will
  54.   // overwrite any previous value the symbol had, and add the symbol
  55.   // if necessary.
  56.   // Takes over ownership of both name and value.
  57.  
  58.   void somtSetSymbolCopyName(in string name, 
  59.                             in string value);
  60.   
  61.   // See somtSetSymbol
  62.   // Only takes over ownership of value.
  63.  
  64.   void somtSetSymbolCopyValue(in string name, 
  65.                              in string value);
  66.   
  67.   // See somtSetSymbol
  68.   // Only takes over ownership of name.
  69.  
  70.   void somtSetSymbolCopyBoth(in string name, 
  71.                             in string value);
  72.   
  73.   // See somtSetSymbol
  74.   // Does not take over ownership of either <name> or <value>
  75.  
  76.   boolean somtCheckSymbol(in string name);
  77.   
  78.   // Returns 1 (true) if the indicated symbol has non-null, non-zero
  79.   // length value, and 0 (false) otherwise.
  80.  
  81.   void somtSetOutputFile(inout FILE fp);
  82.   
  83.   // All template output will be directed to <fp>. Default is <stdout>.
  84.  
  85.   void somto(in string tmplt);
  86.   
  87.   // Outputs a template, <tmplt>, after substitution for any symbols
  88.   // that occur in it.  Five substitutions are supported: simple,
  89.   // list, comment, tab, and conditional.
  90.   // Substitutable items in the template are bracketed with angle
  91.   // brackets. (Backslash can be used to escape an angle bracket.)
  92.   // Simple substitutions just replace a symbol with its value. If
  93.   // the symbol has no value in this template object then the symbol
  94.   // is replaced error string but no error is raised.
  95.   // List substitution assumes that the symbol has a value in output
  96.   // template list form. This is a newline separated string of
  97.   // values. The list substitution specification consists of four
  98.   // parts, a prefix, a symbol, a separator, and a list indicator.
  99.   // prefixes and separators can only be composed of blanks, comma,
  100.   // colons, and semi-colons.  The list indicator is "..." (three
  101.   // periods).  For example, the list substitution
  102.   // specification "<, name, ...> has a prefix of ", ", a symbol of
  103.   // "name" and a separator of ", ".  The prefix will be used
  104.   // whenever there is at least one item in the list and the separator
  105.   // will be used between any two list items.  After the first items
  106.   // of a list is placed each additional item is evaluated to see if
  107.   // it would begin after the line length limit (set by
  108.   // _set_somtLineLength), if it would then a new line is begun and the
  109.   // value is placed directly under the first item.
  110.   // Comment substitution assumes that the symbol has a value in
  111.   // output template list form.  A comment specification consists of
  112.   // a comment indicator followed by a symbol name. The comment
  113.   // indicator is "--".  Eg, <-- classComment> is a valid comment
  114.   // substitution specification.  The lines of the comment are output
  115.   // according to the current comment style (see <somtCommentStyle>)
  116.   // and alined with the starting column of the comment
  117.   // specification.
  118.   // Tab substitution is specified by <@dd> where "dd" is a valid
  119.   // positive integer. Blanks will be inserted into the output stream
  120.   // if necessary to position the next character of output at the
  121.   // column indicated by "dd".
  122.   // Conditional substitution is specified by puting a question mark,
  123.   // "?", in column one of the template line.  The line will not be
  124.   // output at all unless at least one valid, non-blank,  symbol
  125.   // substitution  occurs on the line.
  126.  
  127.   void somtOutputComment(in string comment);
  128.   
  129.   // Inserts a comment into the output stream.  <comment> must be a
  130.   // string containing the comment with lines in the comment
  131.   // seperated by newlines.
  132.   // The style of output is controlled by <somtCommentStyle>
  133.  
  134.   void somtOutputSection(in string sectionName);
  135.   
  136.   // Just like <somto> above, except <sectionName> must be a symbol
  137.   // whose value will be used as the template.
  138.  
  139.   void somtAddSectionDefinitions(in string defString);
  140.   
  141.   // <defString> must be a string of the form:
  142.   // :section1
  143.   // value 1 line 1
  144.   // value 1 line 2
  145.   // :section2
  146.   // value 2 line 1
  147.   // :section3
  148.   // value 3 line 1
  149.   // Where the lines that contain a ":" in column 1 immediately followed
  150.   // by a single name are used to intro the start of a new section.
  151.   // The section is named by the name on the colon line.  A backslash
  152.   // can be used to escape a colon in column one that is not supposed
  153.   // to start a new section.
  154.   // Adds the indicated section definitions to this template.
  155.  
  156.   void somtReadSectionDefinitions(inout FILE fp);
  157.   
  158.   // Reads section definitions from the indicated file.  The section
  159.   // definitions must be in the form defined above in
  160.   // <somtAddSectionDefinitions>.
  161.  
  162.   string somtExpandSymbol(in string s, 
  163.                          in string buf);
  164.   
  165.   // Expands simple symbols in an already expanded string.  Thus if you
  166.   // have a symbol which is itself a Section in a template file, and this
  167.   // section could have other sections in it then you should call this
  168.   // method.
  169.  
  170. #ifdef __SOMIDL__
  171.   implementation {
  172.     releaseorder: _get_somtCommentStyle,_set_somtCommentStyle,_get_somtLineLength, 
  173.                   _set_somtLineLength,_set_somtCommentNewline,_get_somtCommentNewline, 
  174.                   somtGetSymbol,somtSetSymbol,somtSetSymbolCopyName,somtSetSymbolCopyValue, 
  175.                   somtSetSymbolCopyBoth,somtCheckSymbol,somtSetOutputFile, 
  176.                   somto,somtOutputComment,somtOutputSection, 
  177.                   somtAddSectionDefinitions,somtReadSectionDefinitions, 
  178.                   somtExpandSymbol;
  179.   
  180.     //# Class Modifiers
  181.     majorversion = 2;
  182.     minorversion = 1;
  183.     filestem = sctmplt;
  184. #ifdef _WIN32
  185.     dllname = "some.dll";
  186. #endif
  187.     callstyle = oidl;
  188.   
  189.     passthru C_h =        "#include <stdio.h>"
  190. "typedef enum somtCommentStyleT { somtDashesE, somtCPPE, somtCSimpleE, somtCBlockE } somtCommentStyleT;";
  191.     passthru C_xh =        "#include <stdio.h>"
  192. "typedef enum somtCommentStyleT { somtDashesE, somtCPPE, somtCSimpleE, somtCBlockE } somtCommentStyleT;";
  193.   
  194.     //# Internal Instance Variables
  195.     SOMStringTableC stab;           
  196.     FILE *fp;                       
  197.     long currentColumn;             
  198.     boolean conditionalLine;            
  199.     boolean anyExpansions;              
  200.     char oBuf[MAX_OUTPUT_LINE_LENGTH];     
  201.     long oBufPos;                   
  202.   
  203.     //# Method Modifiers
  204.     somInit: override;
  205.     somUninit: override;
  206.     somPrintSelf: override;
  207.     somDumpSelfInt: override;
  208.     somtSetOutputFile: mplan=none;
  209.     somtReadSectionDefinitions: mplan=none;
  210.   };
  211. #endif /* __SOMIDL__ */
  212. };
  213.  
  214.  
  215. #endif  /* sctmplt_idl */
  216.