source: cpp/frams/mhandlers/stderrors.cpp @ 372

Last change on this file since 372 was 372, checked in by sz, 7 years ago

Renamed some classes and functions to make their purpose more obvious:

All MessageHandlers? must now be given the explicit "Enable" argument if you want them to automatically become active. This makes side effects clearly visible.

  • Property svn:eol-style set to native
File size: 988 bytes
1// This file is a part of Framsticks SDK.
2// Copyright (C) 1999-2015  Maciej Komosinski and Szymon Ulatowski.
3// See LICENSE.txt for details.
5#include "stderrors.h"
6#include <frams/util/sstringutils.h>
7#include <common/hmessage.h>
9bool listIndexCheck(SList* list,int index,const char* msgobj,const char* msgfun)
11        int size=list->size();
12if ((index<0)||(index>=size))
13        {
14        if (size>0)
15                Hprintf(msgobj,msgfun,HMLV_ERROR,"Invalid index %d (allowed range is 0..%d)",index,size-1);
16        else
17                Hprintf(msgobj,msgfun,HMLV_ERROR,"Invalid index %d (this list is empty)",index);
18        return 0;
19        }
20return 1;
23SString stringCheck(SString& in,const char* msgobj,const char* msgfun,const char* msg,SString (*checker)(SString& in))
25if (!checker)
26        checker=trim;
27SString corrected=checker(in);
28if (corrected!=in)
29        {
30        SString msg2=SString(msg)+": \"%s\" (adjusted to \"%s\")";
31        Hprintf(msgobj,msgfun,HMLV_WARN,msg2.c_str(),in.c_str(),corrected.c_str());
32        }
33return corrected;
Note: See TracBrowser for help on using the repository browser.