Parcourir la source

Added functioning build.xml

- Fixed a couple of bugs found when trying to make ant build file to work
- Updated .gitignore to include folders created by the build xml file
Fixing-travis-yml
BinHong Lee il y a 7 ans
Parent
révision
ad67a8397b
7 fichiers modifiés avec 134 ajouts et 23 suppressions
  1. +3
    -0
      .gitignore
  2. +102
    -0
      build.xml
  3. +4
    -3
      src/LogInSystem.cpp
  4. +4
    -4
      src/LogInSystem.hpp
  5. +14
    -10
      src/VehicleManager.cpp
  6. +5
    -3
      src/VehicleManager.hpp
  7. +2
    -3
      src/main.cpp

+ 3
- 0
.gitignore Voir le fichier

@@ -1,3 +1,6 @@
bin
obj
# Compiled Object files
*.slo
*.lo


+ 102
- 0
build.xml Voir le fichier

@@ -0,0 +1,102 @@
<?xml version="1.0"?>
<project name="Ticketing System."
default="targets" basedir="."
xmlns:dn="antlib:org.apache.ant.dotnet"
xmlns="antlib:org.apache.tools.ant"
xmlns:cpptasks="antlib:net.sf.antcontrib.cpptasks">
<taskdef resource="cpptasks.tasks"/>
<taskdef resource="net/sf/antcontrib/antcontrib.properties"/>

<property name="src" value="src/"/>

<property name="obj.dir" value="obj"/>
<property name="lib" value="./lib" />
<property name="dist.dir" value="bin"/>
<property environment="env"/>
<property name="user" value="${env.USERNAME}"/>

<path id="compile.classpath">
<pathelement location="${build}"/>
<pathelement path="${lib}/json.jar"/>
</path>

<target name="targets">
<echo message="Targets are clean, build, execute, targets"/>
</target>

<target name="build">
<tstamp/>
<!-- Create the build directory structure used by compile -->
<mkdir dir="${dist.dir}" />
<mkdir dir="${obj.dir}" />

<condition property="build.host.islinux">
<and>
<os family="unix" />
<not>
<contains string="${os.name}" substring="mac"
casesensitive="false"/>
</not>
</and>
</condition>
<condition property="build.host.platform" value="linux">
<isset property="build.host.islinux" />
</condition>

<condition property="build.host.ismac">
<and>
<os family="unix" />
<contains string="${os.name}" substring="mac" casesensitive="false"/>
</and>
</condition>
<condition property="build.host.platform" value="mac">
<isset property="build.host.ismac" />
</condition>

<fail unless="build.host.platform"
message="Building on ${os.name} is not supported" />
<echo message="build.host.platform is: ${build.host.platform}"/>
<if>
<isset property="build.host.ismac"/>
<then>
<echo message="detected a mac host"/>
<property name="includepath" value="/opt/local/include:/usr/local/include"/>
<property name="client.lib.path" value="/opt/local/lib"/>
<property name="client.lib.list" value="c++,jsoncpp,stdc++"/>
</then>
<elseif>
<isset property="build.host.islinux"/>
<then>
<echo message="detected a linux host"/>
<property name="includepath" value="/usr/include/jsoncpp"/>
<property name="client.lib.path" value="/usr/local/lib"/>
<property name="client.lib.list" value="jsoncpp,stdc++"/>
</then>
</elseif>
<else>
<echo message="failed to detect a host I know how to build on"/>
</else>
</if>

<echo message="includepath is ${includepath}"/>
<cc outtype="executable" subsystem="console"
outfile="${dist.dir}/main"
objdir="${obj.dir}">
<includepath>
<pathelement path="${includepath}"/>
</includepath>
<libset dir="${client.lib.path}" libs="${client.lib.list}"/>
<fileset dir="${src}" includes="Person.cpp,LogInSystem.cpp,Vehicle.cpp,VehicleManager.cpp,main.cpp"/>
</cc>
</target>

<target name="execute" depends="build">
<exec executable="./bin/main"/>
</target>

<target name="clean">
<delete dir="${obj.dir}" failonerror="false"/>
<delete dir="${dist.dir}" failonerror="false"/>
</target>

</project>

+ 4
- 3
src/LogInSystem.cpp Voir le fichier

@@ -14,12 +14,13 @@ using namespace std;
LogInSystem::LogInSystem()
{
wrongPass = 0;
}
LogInSystem::LogInSystem(string filename)
{
ifstream fin(filename);
wrongPass = 0;
ifstream fin(filename.c_str());
while (!fin.eof())
{
string username;
@@ -350,7 +351,7 @@ string LogInSystem::chgPhoneNo()
void LogInSystem::toTxtFile(string filename)
{
ofstream fout(filename);
ofstream fout(filename.c_str());
while (!users.empty())
{


+ 4
- 4
src/LogInSystem.hpp Voir le fichier

@@ -3,7 +3,7 @@
#include <json/json.h>
#include <string>
#include <vector>
#include "Person.cpp"
#include "Person.hpp"
using namespace std;
class LogInSystem
@@ -24,10 +24,10 @@ public:
string chgPassword(Person);
string chgEmail();
string chgPhoneNo();
void toTxtFile();
void toTxtFile(string filename);
private:
vector<Person> users;
static int wrongPass = 0;
static int globalUserId;
int wrongPass;
int globalUserId;
};

+ 14
- 10
src/VehicleManager.cpp Voir le fichier

@@ -1,6 +1,9 @@
#include <string>
#include <vector>
#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <stdio.h>
#include <json/json.h>
#include "VehicleManager.hpp"
using namespace std;
@@ -10,16 +13,16 @@ VehicleManager::VehicleManager()
}
VehicleManager::VehicleManager(string jsonFile)
VehicleManager::VehicleManager(string jsonFileName)
{
ifstream jsonFile(jsonFile.c_str());
ifstream jsonFile(jsonFileName.c_str());
Json::Reader reader;
Json::Value vehicles;
ifstream json(jsonFile.c_str(), ifstream::binary);
ifstream json(jsonFileName.c_str(), ifstream::binary);
bool parseSuccess = reader.parse(json, vehicles, false);
bool parseSuccess = reader.parse(json,vehicles,false);
if(parseSuccess)
{
@@ -68,7 +71,7 @@ VehicleManager::VehicleManager(string jsonFile)
bool VehicleManager::add(Vehicle newVehicle)
{
if (newVehicle.getId() <= vehicle.back().getId())
if (newVehicle.getId() <= vehicles.back().getId())
{
return false;
}
@@ -102,7 +105,7 @@ Vehicle VehicleManager::get(int id)
}
}
void VehicleManager::toJson(string jsonFile)
void VehicleManager::toJson(string jsonFileName)
{
Json::Value jsonLib;
@@ -119,21 +122,22 @@ void VehicleManager::toJson(string jsonFile)
jsonVehicle["DateNTime"] = vehicle.getDateNTime();
jsonVehicle["id"] = vehicle.getId();
int* seatMap = new int[vehicle.getLength()][vehicle.getWidth()];
Json::Value seatMap;
for (int i = 0; i < vehicle.getLength(); i++)
{
Json::Value row;
for (int j = 0; j < vehicle.getWidth(); j++)
{
seatMap[i][j] = vehicle.getGuest(i, y);
row.append(vehicle.getGuest(i, j));
}
seatMap.append(row);
}
jsonVehicle["SeatMap"] = seatMap;
}
Json::StyledStreamWriter ssw(" ");
ofstream jsonOutFile(jsonFile.c_str(), ofstream::binary);
ofstream jsonOutFile(jsonFileName.c_str(), ofstream::binary);
ssw.write(jsonOutFile, jsonLib);
}


+ 5
- 3
src/VehicleManager.hpp Voir le fichier

@@ -1,5 +1,7 @@
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include "Vehicle.hpp"
using namespace std;
@@ -10,10 +12,10 @@ private:
public:
VehicleManager();
VehicleManager(string jsonFile);
VehicleManager(string jsonFileName);
bool add(Vehicle newVehicle);
bool remove(Vehicle toRemove);
Vehicle get(int id);
void toJson(string jsonFile);
void toJson(string jsonFileName);
int getId();
}
};

+ 2
- 3
src/main.cpp Voir le fichier

@@ -2,9 +2,8 @@
#include <vector>
#include <iostream>
#include <json/json.h>
#include "VehicleManager.cpp"
#include "LogInSystem.cpp"
#include "Person.cpp"
#include "VehicleManager.hpp"
#include "LogInSystem.hpp"
using namespace std;
int main()


Chargement…
Annuler
Enregistrer