• Content count

  • Joined

  • Last visited

Community Reputation

644 Good

About Flyverse

  • Rank

Personal Information

  • Interests
  1. a hidden spring

    I'm not a designer at all, but as a player I honestly don't think that it blends in too much - Instead, it adds to the kind of "gloomy" feel of the room (Dark colors + not a 100% easy to discern some elements = Acts a bit like a dark room) Not sure if I managed to say what I wanted to say, but you get me
  2. Hi! The question in the title probably sounds very broad, so here are a few more informations about myself. I will be starting my undergraduate program in a few days. The program I am doing is a dual degree in business (B.S. of Economics, focused on entrepreneurship) and technology (B.S. of Engineering, focused on Networked Systems / Cloud Computing). If my scholarship somehow happens to cover a 5th year (which isnt the case right now), I'll be doing an accelerated M.S. as well. If I were to list the types of projects I'd be interested in doing, the list could get quite long, albeit it does get shortened by the irrationality of some of these ideas. The point of both of these informations: 1. I have quite a few "elective" classes at my University. These can be filled by a wide variety of interesting classes - Including a few classes about game design and development. 2. One major interest of mine would still be to get into the industry and develop a game (More as an indie studio than a developer at a big company, however. As I said previously though, it isn't my only interest: which is why I'm unsure of what to do. Basically, my question is whether I should fill the majority of these electives with the game development related classes, or classes of a completely different nature. I know that I read somewhere that one doesn't have to study something related to games in order to break into the industry, but the descriptions of the classes do sound very interesting, so I am truly unsure of what to do. Another factor that may play a role is how I've "acted" the previous years; one may see from my previous posts that I've been interested in game making for a long time, but ALWAYS, without exception, fail at finishing a project of mine. At one point I just start heavily procrastinating until I get an idea for an entirely different project and drop the old one. I know that this is a habit that I will have to somehow drop regardless of the industry I will be getting myself into, but I thought that I'd just out it out here for more information. So, yeah - That's it. I'd really appreciate some advice :)! Thank you very much, and have a nice day.
  3. Improving at programming: Code Review

    Yeah, I know, and I'm really sorry about that! I just had no clue how I could get some judgement on my current ability and what/how I could improve without posting actual code, so I just chose to post a few of the shorter examples I had. If you have a better idea, I'd gladly hear it :)!     Thank you so much! Yeah, the all-caps vector thingies are macros. It was some time ago, but I remember having been really tired of having to write down the iterator-stuff all the time, so I just put them in a macro. What exactly speaks against them, though? As long as the employed method is known, it should be fine, since macro's only are text replacement, right? The rest makes perfect sense, thanks! By the way, might there have been by any chance something "general" you noticed that may indicate my "level" (And thus also what I need to do in order to improve)? Oh well, in any case, thanks!   (More judgements are also always welcome :P )
  4. Heya!   While programming has been one of my hobbies for quite a few years now, I feel like I haven't been progressing a single bit these past two years. Since I taught myself programming by simple trial and error, I'm obviously incredibly far away from a "professional" level - But I'd still have liked to get a bit better. The thing is, that I don't even know what exactly I need to improve - And that's why I thought that it might be really helpful if someone could give a quick look at some of my more recent code, and maybe tell me what I could improve (Not really specific to the code itself, but more in general) The problem is that I obviously can't just post loads of code, since it'd be way too tiring to look through that, so I'll try to just post a few snippets of some code that can hopefully be understood without context as well. In any case, I'd truly appreciate if someone could give me a piece of advice to progress some more, going from the code samples below! Also, I'm really sorry for the length of this, but I couldn't find shorter... Really sorry! I totally understand if this is too much, but I didn't know how I could cut it down to only post snippets. Quick&Dirty StateMachine from a year ago (C++) (Not long after I had started learning C++) StateMachine.h   #ifndef pyH_StateMachine #define pyH_StateMachine #pragma once #include "stdafx.h" #include <memory> #include <map> #include <stack> #include <set> #include "StateMachineEvent.h" #include "EventHandler.h" #include "easylogging++.h" class GameState; typedef std::shared_ptr<GameState> GameStatePtr; class StateMachine { public: StateMachine(EventHandler* eh); /* Destructor also destroys all states. */ ~StateMachine(); /* Adds a state to the state-list, and generates an ID for it. @return int ID - The generated ID of the state */ int addState(GameStatePtr g); /* Removes a state from the state-list. IDs WILL NOT be re-indexed, in case that they were stored somewhere else. */ void removeState(int ID); /* Fetches the state for the given ID. Returns null-pointer if no state was found. @return std:shared_ptr<GameState> - The state with the given ID. */ GameStatePtr getState(int ID); /* Pushes the state found for the given ID on top of the active-states, and focuses it (All other active states will no longer be updated, but still be rendered.) */ void focusState(int ID); /* Pushes the state found for the given ID at the back of the active-states, and focuses the one at the top. (All other active states will no longer be updated, but still be rendered.) */ void unfocusState(int ID); /* Renders a state inactive, thus no longer rendering and updating it. */ void makeInactive(int ID); /* Updates the focused state. */ void update(const float delta); /* Renders all active states, from bottom to top. */ void render(const float interpolation); private: std::map<int, GameStatePtr> gameStates; std::deque<int> activeStateIDs; std::vector<int> inactiveStateIDs; EventHandler* eh; }; #endif StateMachine.cpp   #include "StateMachine.h" #include "GameState.h" #include <iostream> StateMachine::StateMachine(EventHandler* eh) : eh(eh) { //TODO LOG creation } StateMachine::~StateMachine(){ LOG(INFO) << "<StateMachine> Destroyed."; activeStateIDs.clear(); inactiveStateIDs.clear(); for(auto pair : gameStates){ pair.second->exit(); pair.second.reset(); } gameStates.clear(); } int StateMachine::addState(GameStatePtr state){ LOG(INFO) << "<StateMachine> State \"" << state->getName() << "\" added."; int id = gameStates.size(); gameStates[id] = state; eh->triggerEvent<StateMachineEvent>(EventType::StateMachineEvent_Added, 1, id); return id; } void StateMachine::removeState(int ID){ LOG(INFO) << "<StateMachine> State \"" <<>getName() << "\" removed."; VEC_DEL(activeStateIDs, ID); VEC_DEL(inactiveStateIDs, ID);>exit();; gameStates.erase(ID); eh->triggerEvent<StateMachineEvent>(EventType::StateMachineEvent_Removed, 1, ID); } GameStatePtr StateMachine::getState(int ID){ return; } void StateMachine::focusState(int ID){ if(!activeStateIDs.empty() && activeStateIDs.back() == ID) return; VEC_DEL(inactiveStateIDs, ID); VEC_DEL(activeStateIDs, ID); if(gameStates.count(ID)){ activeStateIDs.push_front(ID); } eh->triggerEvent<StateMachineEvent>(EventType::StateMachineEvent_Focused, 1, ID); } void StateMachine::unfocusState(int ID){ if(activeStateIDs.front() == ID) return; VEC_DEL(inactiveStateIDs, ID); VEC_DEL(activeStateIDs, ID); if(gameStates.count(ID)){ activeStateIDs.push_back(ID); } eh->triggerEvent<StateMachineEvent>(EventType::StateMachineEvent_Unfocused, 1, ID); } void StateMachine::makeInactive(int ID){ if(VEC_HAS(inactiveStateIDs, ID)) return; VEC_DEL(activeStateIDs, ID); inactiveStateIDs.push_back(ID); eh->triggerEvent<StateMachineEvent>(EventType::StateMachineEvent_MadeInactive, 1, ID); } void StateMachine::update(const float delta){ if(!activeStateIDs.empty())>update(delta); } void StateMachine::render(const float interpolation){ auto iter = activeStateIDs.rbegin(); while(iter != activeStateIDs.rend()){*iter)->render(interpolation); iter++; } } C++ EventHandler for the same game (That never got anywhere, by the way) #ifndef pyH_EventHandler #define pyH_EventHandler #pragma once #include "Event.h" #include "EventType.h" #include "GameEvent.h" #include "SFML\Graphics.hpp" #include <map> #include <deque> #include "IPoolable.h" #include "stdafx.h" class EventHandler { public: void triggerEvent(EventType type, GameEvent* e); void triggerEvent(sf::Event::EventType type, sf::Event e); template<class T> void triggerEvent(EventType type, int n_args, ...); EventHandler& tmpConstraints(const std::initializer_list<int>& il); void hookInto(sf::Event::EventType type, fastdelegate::FastDelegate1<sf::Event, void> fun); void hookInto(EventType type, fastdelegate::FastDelegate1<GameEvent*, void> fun); ~EventHandler(); EventHandler(); void recycleEvent(EventType type, GameEvent* e); template<class T> GameEvent* newEvent(EventType type, int n_args, ...); private: std::map<sf::Event::EventType, A3D::AEvent<FastDelegate<void (sf::Event)>>> inputEvents; std::map<EventType, A3D::AEvent<FastDelegate<void(GameEvent*)>>> gameEvents; std::map<EventType, std::deque<GameEvent*>> eventPool; template<class T> GameEvent* newEvent(EventType type, va_list l); std::vector<int> tempConstraints; friend class GameEvent; }; #endif #include "EventHandler.h" #include <iostream> //HACK #include "Events.h" //!HACK EventHandler& EventHandler::tmpConstraints(const std::initializer_list<int>& il){ tempConstraints.clear(); for(const auto& i : il){ tempConstraints.push_back(i); } return *this; } void EventHandler::triggerEvent(EventType type, GameEvent* e){ if (gameEvents.count(type) > 0){ for (A3D::HDELEGATE hDG =; hDG !=;){ A3D::HDELEGATE hCurDG = hDG++; VEC1_CONTAINS_VEC2(hCurDG->second, tempConstraints, vecContains); if (hCurDG->second.size() == 0 || vecContains); } } tempConstraints.clear(); } void EventHandler::triggerEvent(sf::Event::EventType type, sf::Event e){ if(inputEvents.count(type) > 0) TRIGGER_EVENT(, e); } template<class T> void EventHandler::triggerEvent(EventType type, int n_args, ...){ va_list args; va_start(args, n_args); this->triggerEvent(type, newEvent<T>(type, args)); va_end(args); } void EventHandler::hookInto(sf::Event::EventType type, FastDelegate1<sf::Event, void> fun){ if (inputEvents.count(type) == 0) inputEvents[type] = A3D::AEvent<FastDelegate<void(sf::Event)>>(); += fun; } void EventHandler::hookInto(EventType type, fastdelegate::FastDelegate1<GameEvent*, void> fun){ if (gameEvents.count(type) == 0) gameEvents[type] = A3D::AEvent<FastDelegate<void(GameEvent*)>>();, tempConstraints); } void EventHandler::recycleEvent(EventType t, GameEvent* e){ e->reset(); if(eventPool.count(t) < 1) eventPool[t] = std::deque<GameEvent*>();; } template<class T> GameEvent* EventHandler::newEvent(EventType type, int n, ...){ va_list args; va_start(args, n); GameEvent* gep = newEvent(type, args); va_end(args); return gep; } template<class T> GameEvent* EventHandler::newEvent(EventType type, va_list l){ GameEvent* gep; if (eventPool.count(type) < 1) eventPool[type] = std::deque<GameEvent*>(); if ( < 1) gep = static_cast<GameEvent*>(new T()); else{ gep =;; } gep->createNew(l); return gep; } EventHandler::~EventHandler(){ VEC_LOOP(eventPool, it){ VEC_LOOP(it->second, it2){ (*it2)->reset(); delete (*it2); } it->second.clear(); } eventPool.clear(); gameEvents.clear(); inputEvents.clear(); } EventHandler::EventHandler(){ } template void EventHandler::triggerEvent<CollisionEvent>(EventType type, int n_args, ...); template void EventHandler::triggerEvent<StateMachineEvent>(EventType type, int n_args, ...); It's the shortest C++ code of mine I found that could be read without that much context, but unfrotunately there are still a few things in there that would need clarification... EventType for example, or VEC_LOOP (just a helper method) As far as I can remember, it did work, although I'm not sure of whether it had memory leaks or not. Then there's some Java code, which is quite recent - I wanted to continue working on the game from back then, but didn't feel like trying to understand my own code again, so I just started a Java project instead. To have as much flexibility as possible, I tried introducing an entity system that would allow me to easily add different types of entities as a plugin later on.   public abstract class Entity { public abstract ParameterDescriptor[] getRequiredParameters(); protected Body body; private int ID; public int ID(){ return ID; } public Entity setID(int id){ if(this.body != null) this.body.setUserData(id); this.ID = id; return this; } public Body getBody(){ return body; } public boolean posInEntity(float x, float y){ if(body == null) return false; for(Fixture f : this.body.getFixtureList()){ if(f.testPoint(x, y)) return true; } return false; } public float getPositionX(){ return this.body.getPosition().x; } public float getPositionY(){ return this.body.getPosition().y; } public void setPosition(float x, float y){ this.body.getPosition().set(x, y); } public abstract void kill(Runnable deadCallback); protected abstract Body createAndSpawnBody(World w); public void spawn(World w){ this.body = createAndSpawnBody(w); }}   public class GameWorld { //Both of these together represent all "things" in the game world. No direct access is given: Instead, helper methods will add entities to both of these. TODO: Non-physical entities? private World world; private Array<Entity> entities; private int idCount = 0; private Deque<Entity> entitiesQueuedForRemoval; private HashMap<String, EntityFactory> entityFactories; //Application functions private Array<EntityFunction> functionsToBeApplied; public void update(float deltaTime){ clearDeadEntities(); world.step(deltaTime, 6, 2); for(Entity currentEntity : this.entities){ //Applying functions for(Iterator<EntityFunction> it = this.functionsToBeApplied.iterator(); it.hasNext();) if( it.remove(); } //Function applying is done, clear array. this.functionsToBeApplied.clear(); } /** * Registers a new type of entity. Always overwrites old registrations, in case they exist. * @param entityTypeName - Name that will be used to spawn an entity. Careful not to create conflicting names. * @param entityFactory - Factory returning a new instance of that entity, with given parameters. */ public void registerEntity(String entityTypeName, EntityFactory entityFactory){ if(entityTypeName == null || entityFactory == null) return; entityFactories.put(entityTypeName, entityFactory); } public boolean isRegistered(String entityTypeName){ return entityFactories.keySet().contains(entityTypeName); } public int addEntity(String entityTypeName, EntityParameter params){ Entity entity = entityFactories.get(entityTypeName).createEntity(params); entity.spawn(world); entities.add(entity.setID(nextID())); return entity.ID(); } private int nextID(){ return idCount++; } public void removeEntity(Entity e){ if(entities.contains(e, false)) entitiesQueuedForRemoval.push(e); } private void clearDeadEntities(){ for(Entity e : entitiesQueuedForRemoval){ entities.removeValue(e, true); if(e.getBody() != null) world.destroyBody(e.getBody()); } entitiesQueuedForRemoval.clear(); } public void applyFunctionToAllEntitiesQueued(EntityFunction function){ this.functionsToBeApplied.add(function); } public void applyFunctionToAllEntitiesInstantly(EntityFunction function) { for(Entity gameEntity : this.entities){ if(function.applyFunctionOn(gameEntity)) break; } } public GameWorld(){ entities = new Array<Entity>(); entitiesQueuedForRemoval = new ArrayDeque<Entity>(); entityFactories = new HashMap<String, EntityFactory>(); world = new World(new Vector2(0, -10), true); world.setContactListener(new Box2DListener()); functionsToBeApplied = new Array<EntityFunction>(); } } The "apply function stuff" can be used like that in the update method of the game:   public void update(final float dt) { this.vector3 = levelCam.screenPosToWorld(Gdx.input.getX(), Gdx.input.getY(), this.vector3); this.hovered = null; EntityFunction() { public boolean applyFunctionOn(Entity foundEntity) { if(foundEntity.posInEntity(vector3.x, vector3.y)){ hovered = foundEntity; return true; } return false; } }); EntityFunction(){ public boolean applyFunctionOn(Entity foundEntity){ controllers.get(foundEntity.getClass()).getController().updateEntity(dt, foundEntity); return false; } });; } I also have an eventhandler in this java version of the game, and a plugin loader to actually load the entity plugins and then fill the world with entities from a level file, but it'll be too much code if I put everything here.   I know that there's way too much code on one hand and not enough code to understand the code I posted on the other hand, but it'd be absolutely awesome to be able to get some suggestions! (Or suggestions about how I should post the code here without having to post too much) Thank you so much.
  5. Okay, great! Nonono, don't get me wrong, that's not what I meant at all! I may have misformulated it a bit. I just had quite a few people I spoke with tell me that they'd like to take the risk of starting their own company or something similar, but can't take the risk anymore because of too many dependencies they created with time. What I basically meant with it was that I'd like to try gaining experience as fast as possible. But yeah, I know that this is kind of like saying "Give me free stuff", so it doesn't really work that way. Anyway. Okay, great! And yeah, I can see how my statements seem contradictory - However, what I meant by it is that I don't want to be a programmer professionally, but instead keep it as a hobby as it is now - It's a skill I'm trying to get better at over time, and put to its best use without losing it. Basically: I want to do as much as I can by myself, and I do think that programming is quite interesting. Actually getting my skill to be somewhere that could be considered for professional work would take way too much time for something that I don't really want to do as a job. Oh god, I think I made this sound even more confusing than before.  That's true, haha. Yeah, I know. That's also the reason that I'm working on a small platformer game with a friend of mine right now - I'm trying to gain some more experience regarding multiple aspects of game development, from coding to art to releasing and advertising it. Everything's obviously very beginner like and it won't amount to much either, but I do hope to get some experience that'll at least help me understand what kind of "things" I could try to learn in my free time while studying to progress faster. I'll start a topic in there soon, then!   Thank you both for your advice, I really appreciate it!   Have a nice evening. 
  6. Okay, great!  What do you think about a joint science/business degree, or joint degrees in general? Those 6 years after my studies, what exactly will I be using them for? Gaining experience in already established studios, I assume? (I know that such an experience-gaining step is obviously compulsory, but I'd preferably like to cut back that step as much as I can possibly can - In order to gain time. The older I get, the more responsibilities I will have (Maybe a family, maybe this maybe that, etc), and thus the less risk I'll be able to take.) What do you think about using my free time while studying to already build up my idea in more detail, including a full game design, business plan and some thoughts about how to implement everything? Basically, for every single one of my projects (Not only those related to game development) I've thought about efficiently using my free time in order to be able to (a) cut on expenses later on (Getting some work done in advance) and (b) get closer to the product I myself imagined. (The biggest problem here is that up to now I've pretty much used all of my time either dreaming or procrastinating, so "using my time" is pretty abstract here.) Great! Thanks for the link, I'll read it all! The articles seem really awesome. In fact, I remember reading a few there already a few years back. Actually, yeah, I did forget to add something in there! Unfortunately though, I kind of feel as if I've forgotten most of it. It was planned to be a bigger part of my post, but, oh well - I'll post it when I remember. One part of it had to do with the fact that you don't see new technically challenging and bigger games releasted too often from different developers than the usual big ones, and that the chances of doing so are thus quite low. Something in that direction - I'll post when I remember correctly! In any case, thank you very much for the help!   PS: Does anyone happen to know how I could get some of my current code reviewed? I know that I'm far from being a good programmer, but I think that I'd be able to progress much faster if I knew what was lacking in the first place.
  7. EDIT: I just noticed I posted this into the wrong sub-forum, I'm so sorry!! Might there be a possibility of moving this thread instead of deleting/closing it? Thank you very much!   Heya! This question I have might turn out to be a little weird. First, let me give you a little background about myself so the context can be understood more easily (I know that this will be very boring and annoying, but I believe that my question will be way too unclear if I don't add this information.): I'm turning 18 soon, and am currently in the process of applying to different universities. Mostly in Germany. I'm interested in a lot of very different things - And game development happens to be one of these interests. Now, game development most certainly is not going to be what I will study. I've thought about either going for a mixed Informatics/Business or a mixed Physics/Business degree (Focusing on the more entrepreneurial side of things). Not because I don't want to eventually get into the gaming industry (Why would I ask the question here if I didn't want to), but because I believe that I'll get the most out of my studies that way. In terms of programming, I started around 7 years ago and am now "OK" at it in general, I guess. I'll now try to explain what I optimally would like to do later on, what problems I believe stand in the way of it, and then well... I guess I'd like to hear your opinion about it :) If I could just snap my fingers and wish for an optimal future, I'd absolutely love to be putting the few game ideas I have into reality without having the restrictions of being an employed programmer, but more or less by coordinating whole projects themselves (Ideally in a well-doing start-up) Before anyone points out how utopic this is, I just want to say: I know that. I know that ideas alone are worthless. Without proper funding, you'll get nowhere. Without a proper organized team, you'll get nowhere. Without X, you'll get nowhere. X being literally one of so so many things. Especially since what I'd optimally like to do wouldn't just be to release a snake or pong game. That alone isn't the only problem, however. Not only do I have no capital whatsoever, but I've also never managed to actually finish one of the countless projects I've started. In terms of real project management, my experience is near zero. Even in terms of programming, I only have the experience I acquired through seven years of trying and failing and reading articles (I haven't had anyone review my code yet, but I really don't think that the outcome would be anything less than eye cancer. I'm exaggerating, but I've felt as if I did not progress at all these past 1-2 years.). I have bits and pieces of knowledge in this and that, but nothing concrete: In other words, to the industry I'd probably be completely worthless. No one in his right mind would join someone without any capital and concrete and profound knowledge on specific topics. And this still isn't everything. Thing is: I don't actually want to be a programmer. As I said above: I'd like to put my own ideas into practice, all the while being able to at one hand manage the project and on the other maybe still contribute something on the technical side. Again: Yes, this sounds utopic, and yes, it absolutely is. However, I still have to ask: What do you think? What do you think of the combination of my kind of "dream job" and path of study? Ideally, I'd obviously like to use the time and lack of constraints I have during my studies to be able to make progress on such projects. I know that everything I've said is far-fetched, but the thing is that I'm actually not quite sure how far-fetched it is. Is it far-fetched in the sense of hard but attainable? If that were to be the case, I think that I'd go for it. If it is far-fetched in the sense of you're wasting your life, I might choose to go down another path - I have quite a few project ideas in completely different disciplines as well, some of which may arguably be easier to attain, especially by going to a research-driven university.   TL;DR: I'm not sure what to do. I have project ideas for completely different disciplines some of which are related to game development. However, those related to game-development sound like the "I don't know programming and am alone and want to code an MMORPG in 2 months" threads (No, this is not my case, yes, this is an extreme example) Any opinions :)? Anything is welcome! Thanks a lot.
  8. Hey guys!   For my newest project I need to be able to identify different frequencies in a specific sound-source (Either the direct input, or some sound file like mp3 or something). I don't know a single thing about sound processing and signal processing and all that stuff, but I hope that I will be able to explain myself. Here's what I'd like to achieve: From a "complete" sound-source such as a mp3-file, I need to be able to analyze it's frequencies in order to understand in which frequency-range a specific sound I recorded lies. From some direct-input OR a complete sound-source such as a mp3-file, I need to be able to: - Extract sound of a frequency between my previously analyzed frequency-range in order to verify my previous analysis. - Detect sound of a frequency between my previously analyzes frequency-range from some continuous input, and somehow do something when it got detected.   As I said, I don't know anything about signal processing, but I heard that a Fast Fourier Transform outputs data that can be interpreted to somehow separate the different frequencies in a sound-file. With Mathematica I tried to apply this algorithm to one of my files, and got a result - But I am not able to interpret it. I know that the output should always be symmetric if real input was given, and that, in my case, the frequencies go from 0Hz to 22k-and-something Hz, but else I don't know anything. I think that I am pretty confused by the fact that there isnt any "time-basis": So I don't know how to know what frequency was present at which point of the sound. Ultimately, I'd like to represent the frequency(ies) in a specific range by some sinusoid-like-curve (I know that the frequency that I should get has a peculiar motive, but I dont know how to get it. The sound is the one of insects by the way.)     Help would be greatly appreciated.   Kind regards  
  9. Another question: I read a bit more about prepared statements, and it seems you can't use them to verify table names etc; What should I do then, if I let the user specify, for example, in which order he wants to sort the result? (I'm requesting this data per GET so the user can change it easily, and thus, until now, I just verified if the variable in question either is equals to "desc" or "asc"...)   And why not simply use mysql_escape_string (Or something)? This is also a function that should include "prevention done by experts", so where is the advantage of prepared statements now, if you exclude performance?   EDIT: Nevermind, found the answer for my second question on google.
  10. Ok then, thanks for the explanation! Kind regards, Flyverse
  11. I know that it deflects SQL Injections. But why use prepared statements, if I can just verify user input myself, before putting it in the string-query?   Pseudo-Code: //Prone to SQL Injections String userInput = ...; String query = "SQL BLABLA" + userInput + "OTHER SQL BLABLA"; //NOT prone to SQL Injections, in my opinion String userInput = verifyUserInput(...); String query = "SQL BLABLA" + userInput + "OTHER SQL BLABLA"; ... function verifyUserInput(String userInput){ if userInput is weird: return default input or something } I mean, most of the time you need to verify the input anyway.
  12. Code Review

    @DoctorGlow (Offtopic Question probably) std::string should be passed by reference? Or should you even pass a pointer to a string instead of the string itself? I always considered a string as a primitive type so I did neither...
  13. The problem is that I have no real clue how parsers are working. I know that I have to convert the original input into tokens and then do stuff with it, but that is as far as my knowledge goes.
  14. Just one more question about regexes... How do I match either "regex1" or "regex2" in the same expression? I tried doing ((regex1)|(regex2)), but it doesnt seem to work on   Here is the actual regex: "((\{\s?for(\w+)\s(\w+)\sin\s(\w+)\s?\}(.+?)\{end\g1\s?})|(\{\s?for(\w+)\s(\w+)\s?\=([0-9]+)\s?\;\s?(\w+)\s?(<|>|>=|<=|==|!=)\s?(\w+)\s?\;\s?(\+\+|\-\-|\|)(\w+)(\+\+|\-\-|\|)\s?\}(.+?)\{end\g1\s?}))" (Sorry for the bad formatting...)   And here are the two cases it should work with: "{for0 index=0; i < 5; |i++}test{end0}" "{for1 test in tests}test{end1}"   Weirdly enough, both expressions are working if they are alone. How do I make them work together?   Kind regards, Flyverse
  15. Yeah, I know, but the problem was that it only replaces the match - And that I can't modify something that is not in the range of the match.   Solved it by changing my regex to include \g1: \{each\s(\w+)\sin\s(\w+)\s?}(.+?)\{end\g1}