Example #1
0
wxString wxTextValidator::IsValid(const wxString& val) const
{
    // wxFILTER_EMPTY is checked for in wxTextValidator::Validate

    if ( HasFlag(wxFILTER_ASCII) && !val.IsAscii() )
        return _("'%s' should only contain ASCII characters.");
    if ( HasFlag(wxFILTER_ALPHA) && !CheckString(wxIsalpha, val) )
        return _("'%s' should only contain alphabetic characters.");
    if ( HasFlag(wxFILTER_ALPHANUMERIC) && !CheckString(wxIsalnum, val) )
        return _("'%s' should only contain alphabetic or numeric characters.");
    if ( HasFlag(wxFILTER_DIGITS) && !CheckString(wxIsdigit, val) )
        return _("'%s' should only contain digits.");
    if ( HasFlag(wxFILTER_NUMERIC) && !wxIsNumeric(val) )
        return _("'%s' should be numeric.");
    if ( HasFlag(wxFILTER_INCLUDE_LIST) && m_includes.Index(val) == wxNOT_FOUND )
        return _("'%s' is invalid");
    if ( HasFlag(wxFILTER_INCLUDE_CHAR_LIST) && !ContainsOnlyIncludedCharacters(val) )
        return _("'%s' is invalid");
    if ( HasFlag(wxFILTER_EXCLUDE_LIST) && m_excludes.Index(val) != wxNOT_FOUND )
        return _("'%s' is invalid");
    if ( HasFlag(wxFILTER_EXCLUDE_CHAR_LIST) && ContainsExcludedCharacters(val) )
        return _("'%s' is invalid");

    return wxEmptyString;
}
Example #2
0
CPath CPath::AddPostfix(const wxString& postfix) const
{
	wxASSERT(postfix.IsAscii());

	CPath result;
	result.m_printable = ::DoAddPostfix(m_printable, postfix);
	result.m_filesystem = ::DoAddPostfix(m_filesystem, postfix);

	return result;
}
Example #3
0
void ExportMP2::AddFrame(struct id3_tag *tp, const wxString & n, const wxString & v, const char *name)
{
   struct id3_frame *frame = id3_frame_new(name);

   if (!n.IsAscii() || !v.IsAscii()) {
      id3_field_settextencoding(id3_frame_field(frame, 0), ID3_FIELD_TEXTENCODING_UTF_16);
   }
   else {
      id3_field_settextencoding(id3_frame_field(frame, 0), ID3_FIELD_TEXTENCODING_ISO_8859_1);
   }

   id3_ucs4_t *ucs4 =
      id3_utf8_ucs4duplicate((id3_utf8_t *) (const char *) v.mb_str(wxConvUTF8));

   if (strcmp(name, ID3_FRAME_COMMENT) == 0) {
      // A hack to get around iTunes not recognizing the comment.  The
      // language defaults to XXX and, since it's not a valid language,
      // iTunes just ignores the tag.  So, either set it to a valid language
      // (which one???) or just clear it.  Unfortunately, there's no supported
      // way of clearing the field, so do it directly.
      id3_field *f = id3_frame_field(frame, 1);
      memset(f->immediate.value, 0, sizeof(f->immediate.value));
      id3_field_setfullstring(id3_frame_field(frame, 3), ucs4);
   }
   else if (strcmp(name, "TXXX") == 0) {
      id3_field_setstring(id3_frame_field(frame, 2), ucs4);
      free(ucs4);

      ucs4 = id3_utf8_ucs4duplicate((id3_utf8_t *) (const char *) n.mb_str(wxConvUTF8));

      id3_field_setstring(id3_frame_field(frame, 1), ucs4);
   }
   else {
      id3_field_setstrings(id3_frame_field(frame, 1), 1, &ucs4);
   }

   free(ucs4);

   id3_tag_attachframe(tp, frame);
}
Example #4
0
void Tags::SetTag(const wxString & name, const wxString & value)
{
   // We don't like empty names
   if (name.empty()) {
      return;
   }

   // Tag name must be ascii
   if (!name.IsAscii()) {
      wxLogError("Tag rejected (Non-ascii character in name)");
      return;
   }

   // All keys are uppercase
   wxString key = name;
   key.UpperCase();

   // Look it up
   TagMap::iterator iter = mXref.find(key);

   if (value.empty()) {
      // Erase the tag
      if (iter == mXref.end())
         // nothing to do
         ;
      else {
         mMap.erase(iter->second);
         mXref.erase(iter);
      }
   }
   else {
      if (iter == mXref.end()) {
         // Didn't find the tag

         // Add a NEW tag
         mXref[key] = name;
         mMap[name] = value;
      }
      else if (iter->second != name) {
         // Watch out for case differences!
         mMap[name] = value;
         mMap.erase(iter->second);
         iter->second = name;
      }
      else {
         // Update the value
         mMap[iter->second] = value;
      }
   }
}
// カラム情報のValidator
bool WxSQLiteTest::ColumnValidator(wxString& clumn)
{
	if (!clumn.IsAscii()) {
		wxMessageBox(wxT("カラム名は英数字で30文字(30Byte)以内でお願いします"));
		return false;
	} else {
		// 文字数が30Byteを超えている場合はダメ
		if (clumn.Len() > 30) {
			wxMessageBox(wxT("カラム名は英数字で30文字(30Byte)以内でお願いします"));
			return false;
			// そうでなければデータベース作成
		} else {
			return true;
		}
	}
}
Example #6
0
impValidator::STATUS impValidatorAscii::operator()(const wxString& check) {
    STATUS next = get_next(check);

    if (next == STATUS_ERROR)
        return STATUS_ERROR;

    if (check.IsAscii()) {
        return next;
    } else {
        if (next == STATUS_WARNING)
            m_reason += wxT(", ");
        if (!m_warn)
            m_reason = wxT("");
        m_reason += _("Value needs to be AscII");
        return m_warn?STATUS_WARNING:STATUS_ERROR;
    }
}
Example #7
0
CPath CPath::AppendExt(const wxString& ext) const
{
	wxASSERT(ext.IsAscii());

	// Though technically, and empty extension would simply 
	// be another . at the end of the filename, we ignore them.
	if (ext.IsEmpty()) {
		return *this;
	}

	CPath result(*this);
	if (ext[0] == wxT('.')) {
		result.m_printable << ext;
		result.m_filesystem << ext;
	} else {
		result.m_printable << wxT(".") << ext;
		result.m_filesystem << wxT(".") << ext;
	}

	return result;
}
Example #8
0
File: Path.cpp Project: geekt/amule
bool CPath::BackupFile(const CPath& src, const wxString& appendix)
{
	wxASSERT(appendix.IsAscii());

	CPath dst = CPath(src.m_filesystem + appendix);

	if (CPath::CloneFile(src, dst, true)) {
		// Try to ensure that the backup gets physically written
#if defined __WXMSW__ || defined __IRIX__
		wxFFile backupFile;
#else
		wxFile backupFile;
#endif
		if (backupFile.Open(dst.m_filesystem)) {
			backupFile.Flush();
		}

		return true;
	}

	return false;
}
Example #9
0
bool CPath::BackupFile(const CPath& src, const wxString& appendix)
{
	wxASSERT(appendix.IsAscii());

	CPath dst = CPath(src.m_filesystem + appendix);

	if (CPath::CloneFile(src, dst, true)) {
		// Try to ensure that the backup gets physically written 
		// Now - does this have any effect reopening a already closed file
		// to flush it ???
#if defined __WXMSW__ || defined __IRIX__
		wxFFile backupFile;
#else
		wxFile backupFile;
#endif
		if (backupFile.Open(dst.m_filesystem)) {
			backupFile.Flush();
		}

		return true;
	}

	return false;
}
Example #10
0
void wxTarOutputStream::SetHeaderPath(const wxString& name)
{
    if (!m_hdr->SetPath(name, GetConv()) || (m_pax && !name.IsAscii()))
        SetExtendedHeader(wxT("path"), name);
}