home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / include / sctmplt.idl < prev    next >
Encoding:
Text File  |  1996-02-21  |  8.1 KB  |  208 lines

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