Home

User Guide

image

Contents

1. flores is is open source and freely available under Apache License 2 0 www apache org licenses LICENSE 2 0 Contributor s CTS is open source and freely available under Eclipse Public License 1 0 1 6 More Information Class Reference Guide created with DoxyGen Tests can be regarded as learning tests Examples 1 7 Disclaimer This documentation is work in progress 2 Setup Unzip the distribution to any directory Example let s assume you installed flores in X development libraries flores This directory will from now on be referred to as the flores root 2 1 Sources add all cts sources from flores root contrib cts add all flores sources from flores root src optional if you want to test flores add tests from flores root test src 2 2 Project Settings spize cc spize flores User Manual flores is not written as managed code otherwise it won t run on Linux so make sure you create an WIN32 umanaged code project e WIN32 Define this when compiling on WIN32 DS Is usually pre defined by the Windows IDE e FLORES EXPORT __ define this when you want to create a DLL from the flores sources 2 2 1 additional include directories add the following directories to the include path flores root include flores root include cts optional if you want to test flores add flores root test include 2 2 2 character set windows only General Project Defaults Character set use MULTI BYT
2. 0 3 4 EOL End of Line indicators vary netween operating systems and applications e lt CR gt lt LF gt Windows style e lt LF gt UNIX style lt LF gt is used by TELNET SMTP HTTP Java Network Applications e NO may be used by an Application implemented in C C sending strings wich already contain a terminating Null The Socket readLine method checks for all these EOL indicators 4 util package spize cc spize flores User Manual 4 1 Properties class Eases the task of reading and writing INI files Without this class one would have to write code like this which is not very convenient char key Nickname char value 80 0 int valueLen GetPrivateProfileString Client section key key a Default value ReturnedString sizeof value Size of ReturnedString ChatClient ini INI File Name if valueLen 0 cout lt lt INI file or section or key not found lt lt endl else cout lt lt value of key lt lt key lt lt is lt lt value lt lt endl 5 dsl package Provides a Generic LexicalAnlyzer and implementations for C and LegalNumbering We are aware that nowadays one would use frameworks like antlr for Java etc yet we maintain these classes maybe out of nostalghia 6 Throwables and Test support 6 1 Design Design of Throwables is inspired by the concept of preconditions and postconditions B
3. E character set 2 2 3 required libraries e On UNIX add libraries rt and pthread e On Windows using Visual C make sure you add the library WS2 32 lib winsock version 2 Bo This library is only required when you use classes from flores net 2 2 4 optional libraries e flores net ReadWriteTest this test uses the JTC Java Threads for C library If you want to run it you need to a add JTC sources available from ftp dreamtime org pub programming c orbacus jtc 2 0 to your project b define _ FLORES_HAVE_JTC__ c add the directory above the JTC installation directory to the include path Example let s assume you installed JTC in X development libraries JTC then add X development libraries to the include path spize cc spize flores User Manual 3 net package 3 1 Overview Some sections of a client or server program using the socket API can be difficult to understand for novice socket programmers In addition these sections are often repetitive e g they are copied and pasted from one application to the next In addition support for TELNET clients raises some subtle issues Yes you are reading right TELNET Reason Students proudly finish their first Client Server project alas at runtime it won t behave as expected Who is the culprit the Client or the Server To answer this question students are advised to use TELNET as a Client If the behaviour is still not as expected it s
4. Meyer flores classes implement preconditions and postconditions 6 2 Classes flores lang Throwable is the parent for all throwables Throwable has two direct subclasses Slip When a precondition is violated a Slip is thrown because you the user did something wrong e g you slipped Panic When a Postcondition is violated a Panic is thrown because we the developers did something wrong Creating an application specific set of expressive Slips and Panics is good practice as in Java O spize cc spize flores User Manual e Available Slips lang NumberFormatsSlip lang Tlegal ArgumentSlip lang Array Index OutOfBoundsSlip 10 FileExistSlip e Available Panics lang BufferTooSmallPanic lang OutOfMemoryPanic 10 FileOpenPanic 10 FileCreatePanic 10 FileRenamePanic 10 FileDeletePanic net CannotCreateSocketPanic net ProtocolPanic 6 3 macros for Testers e assertTrue condition e assertFalse condition e assertSlipped method call Verify that we violated a precodition for example by calling a method with invalid argument s Example assertSlipped myBank withdrawal 100000000 6 4 class for Testers e Statistician call Statistician begin lt TestName gt at the start of your test and and Statistician end lt TestName gt and Statistician will log an passed or failed message DS Ina future release of flores Statistician will count the number of passed and failed a
5. is false this macro throws a Panic nB ensure is a keyword in Eiffel the language created by B Meyer E Example void String insert const String s int pos ensure isConsistent e filraise If you want to throw a sub class of Slip or Panic you could use throw However using the macros O spize cc spize flores User Manual raise ThrowableClassName message or iraise Throwablelnstance has advantages ilraise stores additional information Filename line number where the Slip or Panic was thrown O spize cc
6. spize flores User Manual flores V 4 0 date Sep 2011 1 Introduction The flores library implements classes that are helpful for virtually every C project It s origin is in the 1990 ies that explains that there is a String class since at that time there was no STL string available at least not on Sun Solaris And it explains that flores has it s own test framework nowadays one would use google gtest 1 1 package Overview flores contains the following packages e g namespaces flores diagnostics flores lang flores net flores 10 flores util 1 2 Design Version 4 2011 was completely revamped to make the library more Java like Class names and methods are the same as in Java wherever applicable e We like the class import clause in java so we crated an include directory structure to mimick import syntax include lt flores net Socket h gt looks close to import java net Socket e We like the ability of Java IDE s to structure the file list as a tree sorted by package To achieve this in a C IDE like MSVC source filenames include their package e g namespace the file list in the IDE then looks as follows flores net ServerSocket flores net Socket flores util CTime spize cc spize flores User Manual 1 3 Supported Compilers e Windows Visual Studio 2008 and later e Linux gcc V3 and later 1 4 Supported Operating systems e Windows 32 bit e Linux Unix 1 5 License
7. sserts 6 5 Example void main Statistician begin BankAccount double initialBalance 100 0 double amount 50 0 BankAccount ba initialBalance ba withdrawal amount assertTrue ba getBalance initialBalance amount spize cc spize flores User Manual ba deposit amount assertTrue ba getBalance initialBalance initialBalance 50 0 too much 100 0 BankAccount ca initialBalance assertSlipped ca withdrawal too much assertSlipped ca deposit amount Statistician end BankAccount 6 6 Example output INFO Test for BankAccount begins FINE line 30 ok assert True ba getBalance initialBalance amount FINE line 33 ok assert True ba getBalance initialBalance FINE Insufficient funds in account 2 Balance was 50 Withdrawal was 100 FINE line 44 ok assert Slip ca withdrawal amount FINE gt amount gt 0 lt I flores examples diagnostics bankaccount cpp 48 FINE line 47 ok assert Slip ca deposit amount INFO Test for BankAccount ok 6 7 macros for developers e require condition If the requirement is not met this macro throws a Slip nB require is a keyword in Eiffel the language created by B Meyer E Example void BankAccount deposit double amount require amount gt 0 balance amount e ensure condition If the condition
8. the Server s fault Last not least only on the Windows platform the socket DLL must be initialized properly 3 2 Server Example A simple Echo Server B gt not all lines of code are shown DO full source code can be found in the examples directory of the source code distribution jf file EchoServer cpp description minimalistic implementation terminates after a satisfying the first request Conclusion not very useful just for demonstration kk int main flores net Socket pSocket char line MAXLINE int lineLen unsigned short port ECHO_PORT flores net ServerSocket SS if ss bind port return 1 pSocket ss accept bzero line sizeof line lineLen pSocket gt read line sizeof line pSocket gt write line lineLen spize cc spize flores User Manual delete pSocket return 0 spize cc spize flores User Manual 3 3 Client Example A simple Echo Client D gt not all lines of code are shown DS full source code can be found in the examples directory of the source code distribution int main int argc char argv unsigned short port ECHO PORT char servername 80 char inBuff MAXLINE char outBuff hello flores net Socket sock if sock connect servername port return 1 if sock write outBuff strlen outBuff 1 return 2 if sock read inBuff sizeof inBuff lt 0 return 3 return

Download Pdf Manuals

image

Related Search

Related Contents

  Construction Guide - Oakley Sound Systems  Dexxo Pro RTS  5 年 - 大阪府立大学工業高等専門学校  DWA147X smeg freestanding/built  WAGAN Smart AC Flight150 USB+  Sharp LC-60LE751E 60" Full HD 3D compatibility Wi-Fi Silver LED TV  SMC Networks SMC2586W-G User's Manual  31-082型 31-083型 31-084型 取扱説明書 保証書付 ガス追焚機能付湯    

Copyright © All rights reserved.
Failed to retrieve file