Skip to content
Snippets Groups Projects
Commit bee4229b authored by Nina Džugasová's avatar Nina Džugasová
Browse files

Corrected mistakes in all examples.

parent 5a0c8efe
No related branches found
No related tags found
1 merge request!15Nina
......@@ -33,15 +33,17 @@ target_link_libraries( LoggerExample tnl )
ADD_EXECUTABLE( MathExample MathExample.cpp )
target_link_libraries( MathExample tnl )
ADD_EXECUTABLE( StringExample StringExample.cpp )
target_link_libraries( StringExample tnl )
ADD_EXECUTABLE( StringExampleGetAllocatedSize StringExampleGetAllocatedSize.cpp )
target_link_libraries( StringExampleGetAllocatedSize tnl )
ADD_EXECUTABLE( StringExampleGetSize StringExampleGetSize.cpp )
target_link_libraries( StringExampleGetSize tnl )
ADD_EXECUTABLE( StringExampleGetAllocatedSize StringExampleGetAllocatedSize.cpp )
target_link_libraries( StringExampleGetAllocatedSize tnl )
ADD_EXECUTABLE( StringExampleSetSize StringExampleSetSize.cpp )
target_link_libraries( StringExampleSetSize tnl )
ADD_EXECUTABLE( TimerExample TimerExample.cpp )
target_link_libraries( TimerExample tnl )
\ No newline at end of file
#include <iostream>
#include <ConfigDescription.h>
#include <TNL/Config/ConfigDescription.h>
using namespace TNL;
using namespace std;
int main()
{
ConfigDescription confd;
Config::ConfigDescription confd;
confd.template addEntry< String >("--new-entry","Specific description.");
confd.template addEntryEnum< String >("option1");
confd.template addEntryEnum< String >("option2");
......
......@@ -7,7 +7,7 @@ using namespace std;
int main()
{
File file;
/*File file;
file.open( String("new-file.tnl"), IOMode::write );
String title("Header");
......@@ -19,6 +19,6 @@ int main()
file.read( title2, 4);
file.close();
cout << "title2:" << title2 <<endl;
cout << "title2:" << title2 <<endl;*/
}
#include <iostream>
#include <TNL/ConfigDescription.h>
#include <TNL/Config/ConfigDescription.h>
#include <TNL/Containers/List.h>
#include <TNL/Containers/Array.h>
using namespace TNL;
using namespace std;
int main()
{
template List< int > lst;
List lst;
Containers::List< int > lst;
lst.isEmpty();
lst.Append(1);
......@@ -18,6 +19,6 @@ int main()
lst.Insert(2,1);
Array array;
lst.template toArray< int >(array);
Containers::Array<int> array;
lst.toArray(array);
}
\ No newline at end of file
#include <iostream>
#include <TNL/Logger.h>
#include <TNL/Config::ParameterContainer.h>
#include <TNL/Config/ParameterContainer.h>
using namespace TNL;
using namespace std;
int main()
{
Logger logger(50,stream);
Logger logger(50,cout);
Config::ParameterContainer parameters;
logger.writeSystemInformation(parameters);
......
#include <iostream>
#include <Math.h>
#include <TNL/Math.h>
using namespace TNL;
using namespace std;
......@@ -7,5 +7,5 @@ using namespace std;
int main()
{
isPow2(1024);
roundUpDevision(10,4);
roundUpDivision(10,4);
}
\ No newline at end of file
#include <iostream>
#include <TNL/String.h>
#include <TNL/Containers/List.h>
#include <TNL/File.h>
using namespace TNL;
using namespace std;
......@@ -28,15 +30,16 @@ int main( int argc, char* argv[] )
size = str3.getSize();
cout << "size of string:" << size << "bytes" << endl;*/
String str
setter = str.setString( "Something new" );
String str;
str.setString( "Something new" );
String setter = str;
cout << "setter:" << setter << endl;
const char* getter = str4.getString();
cout << "getter:" << getter << endl;
String word( "computer" ) ;
third_letter = word[2];
char third_letter = word[2];
cout << "third_letter:" << third_letter << endl;
// Operators for C Strings
......@@ -60,7 +63,7 @@ int main( int argc, char* argv[] )
// Operators for Strings
String d1( "Cheese" );
d = d1;
String d = d1;
cout << "d:" << d << endl;
String e( "Mac&" );
......@@ -108,25 +111,27 @@ int main( int argc, char* argv[] )
// replace
String phrase( "Hakuna matata" );
new_phrase = phrase.replace( "a", "u", 2 );
String new_phrase = phrase.replace( "a", "u", 2 );
cout << "new_phrase:" << new_phrase << endl;
// strip
String names(" Josh Martin John Marley Charles ");
better_names = names.strip();
String better_names = names.strip();
cout << "better_names:" << better_names << endl;
// split
String dates("3/4/2005;8/7/2011;11/12/2019");
list_dates = dates.split( list, ';' );
cout << "list_dates:" << list_dates << endl;
Containers::List<String> list;
dates.split( list, ';' );
cout << "list_dates:" << list << endl;
// save
String("Header").save(my-file.tnl); // saves "Header" into file my-file.tnl
File myFile;
String("Header").save(myFile); // saves "Header" into myFile
// load
String strg;
strg.load(my-file.tnl);
strg.load(myFile);
cout << "strg:" << strg << endl;
// get line
......@@ -134,8 +139,8 @@ int main( int argc, char* argv[] )
text << "Hello!" << std::endl;
text << "What's up?" << std::endl;
String str;
str.getLine( text );
cout << "str:" << str << endl;
String string;
string.getLine( text );
cout << "str:" << string << endl;
}
#include <iostream>
#include <TNL/String.h>
using namespace TNL
using namespace TNL;
using namespace std;
int main()
{
String str("my world")
String str("my world");
int alloc_size = str.getAllocatedSize();
cout << "alloc_size:" << alloc_size << endl;
}
\ No newline at end of file
#include <iostream>
#include <TNL/String.h>
using namespace TNL
using namespace TNL;
using namespace std;
int main()
{
String str("my world")
String str("my world");
int size = str.getSize();
cout << "size of string:" << size << "bytes" << endl;
}
......
#include <iostream>
#include <TNL/String.h>
using namespace TNL
using namespace TNL;
using namespace std;
int main()
{
int memory
String memory;
memory.setSize( 256 );
cout << "memory:" << memory << endl;
int memorysize = memory.getSize();
cout << "memory:" << memorysize << endl;
}
#include <iostream>
#include <TNL/Timer.h>
#include <TNL/Logger.h>
#include <unistd.h>
using namespace TNL;
......@@ -16,7 +17,7 @@ int main()
time.reset();
cout << "after reset:" << time.getRealTime() << endl;
// writeLog example
Logger log1(50,stream);
writeLog( log1, 0 );
Logger log1(50,cout);
time.writeLog( log1, 0 );
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment