/////////////////////////////////////////////////////////////// // convert.cpp - demo computational engine // // // // Jim Fawcett, CSE791 - Distributed Objects, Spring 2002 // /////////////////////////////////////////////////////////////// /* This is an example of how to create and use a computational engine in your windows programs. You simply build a module, or modules, that encapsulated the processing required for your interface and add it to your project. There is one strange thing that you must do - that is to #include "stdafx.h" as the first include in all your engine cpp files. If you comment out that include, below, the program will fail to compile, complaining about an unexpected end of file while looking for preprocessor directive. This is a quirk of the MFC architecture. */ #include "stdafx.h" #include #include using namespace std; string convert(const char *text) { double converted; istringstream temp1(text); temp1 >> converted; if(temp1.fail()) return ""; ostringstream temp2; temp2 << converted; return temp2.str(); } //----< test stub >------------------------------------------------ #ifdef TEST_CONVERT #include void main() { cout << "\n Testing Convert Server " << "\n ========================\n"; string test1 = "Four score and seven years ago our forefathers ..."; cout << "\n test1 - input: " << test1 << "\n test1 - output: " << convert(test1.c_str()); string test2 = "3.14159"; cout << "\n test2 - input: " << test2 << "\n test2 - output: " << convert(test2.c_str()); string test3 = "3.14159abcd"; cout << "\n test3 - input: " << test3 << "\n test3 - output: " << convert(test3.c_str()); cout << "\n\n"; } #endif