kwave  18.07.70
MP3EncoderSettings.cpp File Reference
#include "config.h"
#include <QDir>
#include <QLatin1Char>
#include <KConfigGroup>
#include <KSharedConfig>
#include "libkwave/String.h"
#include "MP3EncoderSettings.h"
Include dependency graph for MP3EncoderSettings.cpp:

Go to the source code of this file.

Macros

#define MP3_ENCODER_CONFIG_GROUP   "MP3_Encoder_Settings"
 
#define LOAD(field, key)
 
#define SAVE(field, key)   cfg.writeEntry(key, sanitized(field))
 

Functions

static QString sanitized (const QString &in)
 

Macro Definition Documentation

◆ LOAD

#define LOAD (   field,
  key 
)
Value:
field = \
cfg.readEntry(key, field)

load from config file

Parameters
fieldreceives the value
keyidentifier in the config section

Definition at line 38 of file MP3EncoderSettings.cpp.

Referenced by Kwave::MP3EncoderSettings::load().

◆ MP3_ENCODER_CONFIG_GROUP

#define MP3_ENCODER_CONFIG_GROUP   "MP3_Encoder_Settings"

name of the section in the config file

Definition at line 31 of file MP3EncoderSettings.cpp.

Referenced by Kwave::MP3EncoderSettings::load(), and Kwave::MP3EncoderSettings::save().

◆ SAVE

#define SAVE (   field,
  key 
)    cfg.writeEntry(key, sanitized(field))

save to config file

Parameters
fieldvalue to save
keyidentifier in the config section

Definition at line 46 of file MP3EncoderSettings.cpp.

Referenced by Kwave::MP3EncoderSettings::save().

Function Documentation

◆ sanitized()

static QString sanitized ( const QString &  in)
static

Makes sure that the string does only contain allowed characters, avoid misuse of the command line parameters

Parameters
inpotentially unsafe string
Returns
string with only digits, numbers and '-', '=' and ''

Definition at line 56 of file MP3EncoderSettings.cpp.

References _.

57 {
58  QString out = _("");
59  QString str = in.simplified();
60 
61  for (int i = 0; i < str.length(); i++) {
62  QCharRef c = str[i];
63  if ( c.isLetterOrNumber() || c.isSpace() ||
64  (c == QLatin1Char('-')) || (c == QLatin1Char('%')) ||
65  (c == QLatin1Char('=')) || (c == QLatin1Char('.')) ||
66  (c == QLatin1Char('[')) || (c == QLatin1Char(']')) ||
67  (c == QDir::separator()) )
68  {
69  out += c;
70  }
71  }
72  return out;
73 }
#define _(m)
Definition: memcpy.c:66