方法は、簡単。
ブラウザ内で、各モジュール配下のオブジェクトを選択>右クリック>ファイルにエクスポート...
で、出力される。
オブジェクトの種類によって、拡張子はいろいろ:.bas, .cls, {.frm, frx} だけどね。
フォームの場合は、ソース・コードそのものとバイナリ・ファイルのペアが出力されるね。
バイナリ・ファイルのほうは、ジオメトリックな情報なんだろうね。
11. Safariがサポートしているプラグインの種類を教えてください。
Safariのすべてのバージョンで、Netscapeスタイルのプラグインをサポートしています。Safari 1.3以降では、NetscapeスタイルのプラグインとCocoaプラグインをサポートしています。クロスプラットフォームではありませんが、Cocoaプラグインは簡単に作成でき、お使いのプラグインはCocoaのフレームワークのすべてを活用できます。Cocoaプラグインの作成に関する詳細については、「Web Kit Plug-In Programming Topic」を参照し、Xcodeに含まれているWeb Kitサンプルのディレクトリにあるサンプルプラグインを試してみてください。
#include <iostream>
#include <string>
#include <sstream>
string f (string& incoming) // incoming は "foo N"
{
istringstream incoming_stream(incoming);
string the_word;
int the_number;
incoming_stream >> the_word // "foo" を抽出
>> the_number; // "N" を抽出
ostringstream output_stream;
output_stream << "The word was " << the_word
<< " and 3*N was " << (3*the_number);
return output_stream.str();
}
CString suffers from a common programming error that results in
poor performance. Consider the following code:
CString は、プアなパフォーマンスとなる一般的なプログラミング・エラー
の影響をうける。以下のコード例をかんがえよう:
CString n_copies_of (const CString& foo, unsigned n)
{
CString tmp;
for (unsigned i = 0; i < n; i++)
tmp += foo;
return tmp;
}
This function is O(n^2), not O(n). The reason is that each +=
causes a reallocation and copy of the existing string. Microsoft
applications are full of this kind of thing (quadratic performance
on tasks that can be done in linear time) -- on the other hand,
we should be thankful, as it's created such a big market for high-end
ix86 hardware. :-)
この関数は O(n^2)であって、O(n)ではない。理由は、ループ中毎回+=演算子が
メモリの再アロケーションと既存の文字列のコピーをおこなうからだ。Microsoftの
アプリケーションはこの類の問題に満ちている(線形時間で解ける問題が
��乗オーダの性能)--ただ一方でこれは感謝すべきなんだ。ハイ・エンドのix86
ハードウェアの巨大市場を創出しているんだからね(笑)。
If you replace CString with string in the above function, the
performance is O(n).
上記関数で CString を string に置き換えれば、パフォーマンスは O(n) だ。
#include <string>
#include <algorithm>
#include <cctype> // 古い <ctype.h>
struct ToLower
{
char operator() (char c) const { return std::tolower(c); }
};
struct ToUpper
{
char operator() (char c) const { return std::toupper(c); }
};
int main()
{
std::string s ("Some Kind Of Initial Input Goes Here");
// すべてを大文字に変える
std::transform (s.begin(), s.end(), s.begin(), ToUpper());
// すべてを小文字に変える
std::transform (s.begin(), s.end(), s.begin(), ToLower());
// すべてを大文字に変えるが、変換結果を
// 別の文字列変数に格納
std::string capital_s;
capital_s.resize(s.size());
std::transform (s.begin(), s.end(), capital_s.begin(), ToUpper());
}
char toLower (char c)
{
return std::tolower(c);
}
std::string str (" \t blah blah blah \n ");
// 先頭のホワイト・スペースをトリム
string::size_type notwhite = str.find_first_not_of(" \t\n");
str.erase(0,notwhite);
// 末尾のホワイト・スペースをトリム
notwhite = str.find_last_not_of(" \t\n");
str.erase(notwhite+1);
Path: GUIDE.txt Last Update: Tue Dec 04 19:36:28 -0800 2007
require 'rubygems' require 'mechanize' agent = WWW::Mechanize.new
page = agent.get('http://google.com/')
page.links.each do |link| puts link.text end
page = agent.click page.links.find { |l| l.text == 'News' }
page = agent.click page.links.text('News')
agent.click page.links.text('News')[1]
page.links.href('/something')
page.links.text('News').href('/something')
require 'rubygems'
require 'mechanize'
agent = WWW::Mechanize.new
page = agent.get('http://google.com/')
pp page
google_form = page.form('f')
google_form.q = 'ruby mechanize'
#<WWW::Mechanize::Field:0x1403488 @name="q", @value="ruby mechanize">
page = agent.submit(google_form, google_form.buttons.first) pp page
require 'rubygems'
require 'mechanize'
agent = WWW::Mechanize.new
page = agent.get('http://google.com/')
google_form = page.form('f')
google_form.q = 'ruby mechanize'
page = agent.submit(google_form)
pp page
form.fields.name('list').options[0].select
form.checkboxes.name('box').check
form.radiobuttons.name('box')[1].check
form.file_uploads.file_name = "somefile.jpg"
agent.get('http://someurl.com/').search("//p[@class='posted']")
2014-05-13追記: 最新の OptionParser の網羅的機能については、「Ruby OptionParser クラスのリファレンス」 を参照してください。
#! /usr/bin/ruby
#filename: test-optparse.rb
#author: http://voidptr.seesaa.net
#date: Mar. 11th, 2008
#desc:
#ref.: http://stdlib.rubyonrails.org
#
####
require 'optparse';
require 'ostruct';
require 'pp';
#### Option Parse Method.
def option_parse( args )
#Prepare.
ost = OpenStruct.new;
#default option values.
#
#
ost.help = "";
ost.file = "";
ost.kind = "";
ost.logfile = "test.log";
ost.verbose = false;
ost.arr = [];
#
op = OptionParser.new do |opars|
opars.banner = "NAME "+" #{$0} [options]";
opars.separator "";
opars.separator "";
#display -h description at tail of the help message.
#
#
#on_headだと、help表示のとき他のオプションとの間に改行される。
#お好みで。
#opars.on_head( "--version", "show the version." ) do
opars.on( "--version", "show the version." ) do
puts "green 1.0.0";
exit 1;
end
#オペランドありオプション(基本形; オペランドFILEは、必須)
#
#
opars.on( "-f FILE", "specify a file" ) do |f|
ost.file = f;
end
#オペランドありオプション(基本形+; オペランドKINDは必須で、値は選択式・短縮形も可)
#-k a で、-k afterと同じ。-k b で、-k before と同じ意味。
#
#
opars.on( "-k KIND", [:before, :after], "select a kind {before, after}" ) do |k|
ost.kind = k;
end
#オペランドありオプション(基本形++; オペランドは、省略可)
#
#
#
opars.on( "-l [LOGFILE]", "specify the logfile." ) do |l|
if ( l != nil ) then
ost.logfile = l;
end
end
#フラグタイプのオプション (オプションは長い形式もあり; offの形式も同時に定義)
#
#
opars.on( "-v", "--[no-]verbose", "verbose mode switch." ) do |v|
ost.verbose = v;
end
#フラグタイプのオプション
# on_tail で、オプション定義の〆
#
opars.on_tail( "-t", "--tasukete", "show this message." ) do
puts opars;
exit 1;
end
end #endof do |opars|.
####
#オプションなしの場合.
#
#
if ( args == [] ) then
#ヘルプを表示。
puts op;
exit 1;
end
#
op.parse!( args );
#必須オプションのチェック
#
#
if ( ost.file == "" ) then
e = OptionParser::ParseError.new;
e.reason = "file was NOT specified (#{ost.file}).";
throw e;
exit 1;
end
#
ost;
end #endof option_parse
#### Do.
options = option_parse(ARGV)
#### Result.
pp ARGV;
puts "";
pp "Dumper #{options}"
puts "name: #{$0}";
####endof filename: test-optparse.rb