home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / csso0301.zip / SAMPLES / CPP-API / SOURCE / KCTSTLIB.CPP < prev    next >
Text File  |  2000-02-15  |  2KB  |  63 lines

  1. /*  Copyright (c) 1998-2000 IBK-Landquart-Switzerland. All rights reserved.
  2.  *
  3.  *  Module      :  KcTstLib.CPP
  4.  *  Application :  CSS Sample Library
  5.  *  Author      :  Peter Koch, IBK
  6.  *
  7.  *  Date        Description                                 Who
  8.  *  --------------------------------------------------------------------------
  9.  *  Jan 1998    First release                               P.Koch, IBK
  10.  *  Feb 2000    Revised                                     P.Koch, IBK
  11.  */
  12.  
  13. #include <strstrea.h>
  14. #include <KCss.hpp>
  15.  
  16. static IString myStrReverse(KCss* css)
  17. {
  18.    return IString(css->get("string").reverse());
  19. }
  20.  
  21. static IString mySubString(KCss* css)
  22. {
  23.    int argc = css->get("argCount").asInt();
  24.    switch (argc) {
  25.       case 2:
  26.          return css->get("string").subString(
  27.                    css->get("start").asInt()
  28.                 );
  29.       case 3:
  30.          return css->get("string").subString(
  31.                    css->get("start").asInt(),
  32.                    css->get("count").asInt()
  33.                 );
  34.       default:
  35.          return css->get("string").subString(
  36.                    css->get("start").asInt(),
  37.                    css->get("count").asInt(),
  38.                    css->get("padchar")[1]
  39.                 );
  40.    } // switch
  41. } // mySubString
  42.  
  43. void _Export initialize(KCss* css)
  44. {
  45.    IString iFile("KcMyLib.dll");
  46.    istrstream init("const myVersion = 0.1;\n");
  47.    css->loadScript(iFile, &init);
  48.    (*css)
  49.       .addFunc(
  50.           iFile,
  51.          "myStrReverse(const string)",
  52.           myStrReverse)
  53.       .addFunc(
  54.           iFile,
  55.          "mySubString(const string, const start, [const count, const padchar])",
  56.           mySubString);
  57. } // initialize
  58.  
  59. void _Export cleanup(KCss* css)
  60. {
  61. } // cleanup
  62.  
  63.