Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed string to int cast

  • Loading branch information...
commit 5833aba1899b616fbd8876d956f268cda6da0277 1 parent d0126a1
@njoubert njoubert authored
View
1  include/adj/adj_Song.h
@@ -105,7 +105,6 @@ class SongFactory {
std::string get_uuid();
std::string base_song_directory_path_;
- std::string song_database_file_;
Json::Value song_database_;
std::map<SongId, SongPtr> song_map_;
View
20 src/adj/adj_Song.cpp
@@ -91,9 +91,7 @@ int Song::time_remaining() {
SongFactory::SongFactory() {
base_song_directory_path_ = "/data/songs/";
- // This should be a resource. Sadly, Windows has issues
- // loading a text as a resource.
- song_database_file_ = "/data/crowdtap.json";
+
}
void SongFactory::parse_song_database_file() {
@@ -103,7 +101,7 @@ void SongFactory::parse_song_database_file() {
ci::IStreamUrlRef urlRef;
- std::string url_string = "http://djdp.njoubert.com/songs.json";
+ std::string url_string = "http://djdp.njoubert.com/songs_json.php";
try {
urlRef = ci::IStreamUrl::createRef(url_string);
@@ -117,12 +115,14 @@ void SongFactory::parse_song_database_file() {
// assign the char array to string using the size of the buffer array
std::string root;
root.assign(j,j+buf.getDataSize());
-
+
// root now contains the vote json
Json::Reader reader;
Json::Value votes;
- reader.parse(root, song_database_);
+ if (!reader.parse(root, song_database_)) {
+ printf("JSON could not parse\n");
+ }
}
//
@@ -132,14 +132,16 @@ void SongFactory::load_song_database() {
Json::Value& songs_array = song_database_["songs"];
if (songs_array.empty())
- throw (std::runtime_error("Could not find song database file."));
+ throw (std::runtime_error("Song database is empty"));
SongId song_id;
for (Json::Value::iterator it = songs_array.begin(); it != songs_array.end(); ++it) {
Json::Value& song = (*it);
- song_id = song["id"].asInt();
-
+ song_id = boost::lexical_cast<int>(song["id"].asString().c_str());
+
+ printf("Creating song with id %d\n", song_id);
+
song_map_[song_id] = create_song(song_id, song);
}
View
2  src/adj/adj_User.cpp
@@ -245,7 +245,7 @@ void UserFactory::update_nodes_after_user_change(UserPtr user) {
for (std::deque<SongId>::iterator it = user->voted_songs().begin();
it != user->voted_songs().end(); ++it) {
-
+ printf("Updating nodes after user change, song id: %d\n", *it);
song_map[*it]->update_appearance();
}
}
View
2  src/adj/adj_Visualizer.cpp
@@ -44,7 +44,7 @@ void Visualizer::setup() {
// load database from file, create song objects
SongFactory::instance().load_song_database();
} catch (...) {
- ci::app::console() << "Could not find database file, exiting." << std::endl;
+ ci::app::console() << "Could not build song database." << std::endl;
exit;
}
}
View
5 xcode/adj.xcodeproj/project.pbxproj
@@ -514,15 +514,18 @@
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = (
+ /opt/local/include,
"$(CINDER_PATH)/boost",
../include,
"$(CINDER_PATH)/include",
);
+ LIBRARY_SEARCH_PATHS = /opt/local/lib;
ONLY_ACTIVE_ARCH = YES;
OTHER_LDFLAGS = "$(CINDER_PATH)/lib/libcinder_d.a";
PREBINDING = NO;
SDKROOT = macosx10.6;
USER_HEADER_SEARCH_PATHS = "$(CINDER_PATH)/include";
+ VALID_ARCHS = i386;
};
name = Debug;
};
@@ -545,7 +548,7 @@
PREBINDING = NO;
SDKROOT = macosx10.6;
USER_HEADER_SEARCH_PATHS = "$(CINDER_PATH)/include";
- VALID_ARCHS = "i386 x86_64";
+ VALID_ARCHS = i386;
};
name = Release;
};
Please sign in to comment.
Something went wrong with that request. Please try again.